pub enum Message {
Text(String),
Binary(Vec<u8, Global>),
Ping(Vec<u8, Global>),
Pong(Vec<u8, Global>),
Close(Option<CloseFrame<'static>>),
Frame(Frame),
}
Expand description
An enum representing the various forms of a WebSocket message.
Variants
Text(String)
A text WebSocket message
Binary(Vec<u8, Global>)
A binary WebSocket message
Ping(Vec<u8, Global>)
A ping message with the specified payload
The payload here must have a length less than 125 bytes
Pong(Vec<u8, Global>)
A pong message with the specified payload
The payload here must have a length less than 125 bytes
Close(Option<CloseFrame<'static>>)
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 text<S>(string: S) -> Messagewhere
S: Into<String>,
pub fn text<S>(string: S) -> Messagewhere
S: Into<String>,
Create a new text WebSocket message from a stringable.
pub fn binary<B>(bin: B) -> Messagewhere
B: Into<Vec<u8, Global>>,
pub fn binary<B>(bin: B) -> Messagewhere
B: Into<Vec<u8, Global>>,
Create a new binary WebSocket message by converting to Vec
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
impl Eq for Message
impl StructuralEq for Message
impl StructuralPartialEq for Message
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.