pub struct Client<'a, T> { /* private fields */ }
Expand description
Websocket client handshake.
Implementations§
source§impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client<'a, T>
impl<'a, T: AsyncRead + AsyncWrite + Unpin> Client<'a, T>
sourcepub fn new(socket: T, host: &'a str, resource: &'a str) -> Self
pub fn new(socket: T, host: &'a str, resource: &'a str) -> Self
Create a new client handshake for some host and resource.
sourcepub fn set_buffer(&mut self, b: BytesMut) -> &mut Self
pub fn set_buffer(&mut self, b: BytesMut) -> &mut Self
Override the buffer to use for request/response handling.
sourcepub fn take_buffer(&mut self) -> BytesMut
pub fn take_buffer(&mut self) -> BytesMut
Extract the buffer.
sourcepub fn set_headers(&mut self, h: &'a [Header<'_>]) -> &mut Self
pub fn set_headers(&mut self, h: &'a [Header<'_>]) -> &mut Self
Set connection headers to a slice. These headers are not checked for validity, the caller of this method is responsible for verification as well as avoiding conflicts with internally set headers.
sourcepub fn add_protocol(&mut self, p: &'a str) -> &mut Self
pub fn add_protocol(&mut self, p: &'a str) -> &mut Self
Add a protocol to be included in the handshake.
sourcepub fn add_extension(&mut self, e: Box<dyn Extension + Send>) -> &mut Self
pub fn add_extension(&mut self, e: Box<dyn Extension + Send>) -> &mut Self
Add an extension to be included in the handshake.
sourcepub fn drain_extensions(
&mut self
) -> impl Iterator<Item = Box<dyn Extension + Send>> + '_
pub fn drain_extensions( &mut self ) -> impl Iterator<Item = Box<dyn Extension + Send>> + '_
Get back all extensions.
sourcepub async fn handshake(&mut self) -> Result<ServerResponse, Error>
pub async fn handshake(&mut self) -> Result<ServerResponse, Error>
Initiate client handshake request to server and get back the response.
sourcepub fn into_builder(self) -> Builder<T>
pub fn into_builder(self) -> Builder<T>
Turn this handshake into a connection::Builder
.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Get out the inner socket of the client.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> !RefUnwindSafe for Client<'a, T>
impl<'a, T> Send for Client<'a, T>where T: Send,
impl<'a, T> !Sync for Client<'a, T>
impl<'a, T> Unpin for Client<'a, T>where T: Unpin,
impl<'a, T> !UnwindSafe for Client<'a, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more