Enum Message
pub enum Message {
Text(Utf8Bytes),
Binary(Bytes),
Ping(Bytes),
Pong(Bytes),
Close(Option<CloseFrame>),
Frame(Frame),
}Available on crate feature
ws only.Expand description
An enum representing the various forms of a WebSocket message.
Variants§
Text(Utf8Bytes)
A text WebSocket message
Binary(Bytes)
A binary WebSocket message
Ping(Bytes)
A ping message with the specified payload
The payload here must have a length less than 125 bytes
Pong(Bytes)
A pong message with the specified payload
The payload here must have a length less than 125 bytes
Close(Option<CloseFrame>)
A close message with the optional close frame.
Frame(Frame)
Raw frame. Note, that you’re not going to get this value while reading the message.
Implementations§
§impl Message
impl Message
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the WebSocket message has no content. For example, if the other side of the connection sent an empty string.
Trait Implementations§
Source§impl<S> Sink<Message> for CompatWebSocketStream<S>
impl<S> Sink<Message> for CompatWebSocketStream<S>
Source§fn poll_ready(
self: Pin<&mut CompatWebSocketStream<S>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>>
fn poll_ready( self: Pin<&mut CompatWebSocketStream<S>>, cx: &mut Context<'_>, ) -> Poll<Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>>
Attempts to prepare the
Sink to receive a value. Read moreSource§fn start_send(
self: Pin<&mut CompatWebSocketStream<S>>,
item: Message,
) -> Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>
fn start_send( self: Pin<&mut CompatWebSocketStream<S>>, item: Message, ) -> Result<(), <CompatWebSocketStream<S> as Sink<Message>>::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§fn poll_flush(
self: Pin<&mut CompatWebSocketStream<S>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>>
fn poll_flush( self: Pin<&mut CompatWebSocketStream<S>>, cx: &mut Context<'_>, ) -> Poll<Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>>
Flush any remaining output from this sink. Read more
Source§fn poll_close(
self: Pin<&mut CompatWebSocketStream<S>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>>
fn poll_close( self: Pin<&mut CompatWebSocketStream<S>>, cx: &mut Context<'_>, ) -> Poll<Result<(), <CompatWebSocketStream<S> as Sink<Message>>::Error>>
Flush any remaining output and close this sink, if necessary. Read more
impl Eq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl !Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more