Enum Message
pub enum Message {
Text(Utf8Bytes),
Binary(Bytes),
Ping(Bytes),
Pong(Bytes),
Close(Option<CloseFrame>),
Frame(Frame),
}
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.
pub fn into_text(self) -> Result<Utf8Bytes, ProtocolError>
pub fn into_text(self) -> Result<Utf8Bytes, ProtocolError>
Attempt to consume the WebSocket message and convert it to a String.
pub fn to_text(&self) -> Result<&str, ProtocolError>
pub fn to_text(&self) -> Result<&str, ProtocolError>
Attempt to get a &str from the WebSocket message, this will try to convert binary data to utf8.
Trait Implementations§
§impl<T> Sink<Message> for AsyncWebSocket<T>
impl<T> Sink<Message> for AsyncWebSocket<T>
§type Error = ProtocolError
type Error = ProtocolError
§fn poll_ready(
self: Pin<&mut AsyncWebSocket<T>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>>
fn poll_ready( self: Pin<&mut AsyncWebSocket<T>>, cx: &mut Context<'_>, ) -> Poll<Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>>
Sink
to receive a value. Read more§fn start_send(
self: Pin<&mut AsyncWebSocket<T>>,
item: Message,
) -> Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>
fn start_send( self: Pin<&mut AsyncWebSocket<T>>, item: Message, ) -> Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>
poll_ready
which returned Poll::Ready(Ok(()))
. Read more§fn poll_flush(
self: Pin<&mut AsyncWebSocket<T>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>>
fn poll_flush( self: Pin<&mut AsyncWebSocket<T>>, cx: &mut Context<'_>, ) -> Poll<Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>>
§fn poll_close(
self: Pin<&mut AsyncWebSocket<T>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>>
fn poll_close( self: Pin<&mut AsyncWebSocket<T>>, cx: &mut Context<'_>, ) -> Poll<Result<(), <AsyncWebSocket<T> as Sink<Message>>::Error>>
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 UnwindSafe for Message
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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
key
and return true
if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more§impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
type Error = <U as RamaTryFrom<T>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
type Error = <U as RamaTryFrom<T>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.