pub struct WebSocketSender { /* private fields */ }Expand description
Sending part of a WebSocket.
The WebSocket is closed when both the WebSocketSender and WebSocketReceiver are dropped.
Implementationsยง
Sourceยงimpl WebSocketSender
impl WebSocketSender
Sourcepub fn protocol(&self) -> &str
pub fn protocol(&self) -> &str
A string representing the sub-protocol used to open the current WebSocket connection.
Sourcepub fn close(self)
pub fn close(self)
Closes the WebSocket.
This also closes the corresponding WebSocketReceiver.
Sourcepub fn close_with_reason(self, code: CloseCode, reason: &str)
pub fn close_with_reason(self, code: CloseCode, reason: &str)
Closes the WebSocket with the specified close code and reason.
This also closes the corresponding WebSocketReceiver.
ยงPanics
Panics if the close code is neither CloseCode::NormalClosure nor CloseCode::Other with a value between 3000 and 4999.
Trait Implementationsยง
Sourceยงimpl AsyncWrite for WebSocketSender
impl AsyncWrite for WebSocketSender
Sourceยงfn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from
buf into the object. Read moreSourceยงfn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Attempts to flush the object, ensuring that any buffered data reach
their destination. Read more
Sourceยงfn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Initiates or attempts to shut down this writer, returning success when
the I/O connection has completely shut down. Read more
Sourceยงfn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
Like
poll_write, except that it writes from a slice of buffers. Read moreSourceยงfn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Determines if this writer has an efficient
poll_write_vectored
implementation. Read moreSourceยงimpl Debug for WebSocketSender
impl Debug for WebSocketSender
Sourceยงimpl Sink<&[u8]> for WebSocketSender
impl Sink<&[u8]> for WebSocketSender
Sourceยงfn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSourceยงfn start_send(self: Pin<&mut Self>, item: &[u8]) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: &[u8]) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreSourceยงimpl Sink<&str> for WebSocketSender
impl Sink<&str> for WebSocketSender
Sourceยงfn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSourceยงfn start_send(self: Pin<&mut Self>, item: &str) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: &str) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreSourceยงimpl Sink<Msg> for WebSocketSender
impl Sink<Msg> for WebSocketSender
Sourceยงfn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSourceยงfn start_send(self: Pin<&mut Self>, item: Msg) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: Msg) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreSourceยงimpl Sink<String> for WebSocketSender
impl Sink<String> for WebSocketSender
Sourceยงfn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSourceยงfn start_send(self: Pin<&mut Self>, item: String) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: String) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreSourceยงimpl Sink<Vec<u8>> for WebSocketSender
impl Sink<Vec<u8>> for WebSocketSender
Sourceยงfn poll_ready(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSourceยงfn start_send(self: Pin<&mut Self>, item: Vec<u8>) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: Vec<u8>) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready which returned Poll::Ready(Ok(())). Read moreAuto Trait Implementationsยง
impl Freeze for WebSocketSender
impl !RefUnwindSafe for WebSocketSender
impl !Send for WebSocketSender
impl !Sync for WebSocketSender
impl Unpin for WebSocketSender
impl !UnwindSafe for WebSocketSender
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
Sourceยงimpl<T, Item> SinkExt<Item> for T
impl<T, Item> SinkExt<Item> for T
Sourceยงfn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>
fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>
Composes a function in front of the sink. Read more
Sourceยงfn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>
fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>
Composes a function in front of the sink. Read more
Sourceยงfn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>
fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>
Transforms the error returned by the sink.
Sourceยงfn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>
fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>
Map this sinkโs error to a different error type using the
Into trait. Read moreSourceยงfn buffer(self, capacity: usize) -> Buffer<Self, Item>where
Self: Sized,
fn buffer(self, capacity: usize) -> Buffer<Self, Item>where
Self: Sized,
Adds a fixed-size buffer to the current sink. Read more
Sourceยงfn flush(&mut self) -> Flush<'_, Self, Item>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self, Item>where
Self: Unpin,
Flush the sink, processing all pending items. Read more
Sourceยงfn send(&mut self, item: Item) -> Send<'_, Self, Item>where
Self: Unpin,
fn send(&mut self, item: Item) -> Send<'_, Self, Item>where
Self: Unpin,
A future that completes after the given item has been fully processed
into the sink, including flushing. Read more
Sourceยงfn feed(&mut self, item: Item) -> Feed<'_, Self, Item>where
Self: Unpin,
fn feed(&mut self, item: Item) -> Feed<'_, Self, Item>where
Self: Unpin,
A future that completes after the given item has been received
by the sink. Read more
Sourceยงfn send_all<'a, St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St>
fn send_all<'a, St>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St>
A future that completes after the given stream has been fully processed
into the sink, including flushing. Read more
Sourceยงfn right_sink<Si1>(self) -> Either<Si1, Self>
fn right_sink<Si1>(self) -> Either<Si1, Self>
Sourceยงfn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>where
Self: Unpin,
fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>>where
Self: Unpin,
A convenience method for calling
Sink::poll_ready on Unpin
sink types.Sourceยงfn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>where
Self: Unpin,
fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>where
Self: Unpin,
A convenience method for calling
Sink::start_send on Unpin
sink types.