Enum tungstenite::Message
source · pub enum Message {
Text(String),
Binary(Vec<u8>),
Ping(Vec<u8>),
Pong(Vec<u8>),
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>)
A binary WebSocket message
Ping(Vec<u8>)
A ping message with the specified payload
The payload here must have a length less than 125 bytes
Pong(Vec<u8>)
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§
source§impl Message
impl Message
sourcepub 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.
sourcepub fn binary<B>(bin: B) -> Messagewhere
B: Into<Vec<u8>>,
pub fn binary<B>(bin: B) -> Messagewhere
B: Into<Vec<u8>>,
Create a new binary WebSocket message by converting to Vec
sourcepub 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.