Enum tungstenite::protocol::Message
[−]
[src]
pub enum Message { Text(String), Binary(Vec<u8>), }
An enum representing the various forms of a WebSocket message.
Variants
Text(String)
A text WebSocket message
Binary(Vec<u8>)
A binary WebSocket message
Methods
impl Message
[src]
fn text<S>(string: S) -> Message where S: Into<String>
Create a new text WebSocket message from a stringable.
fn binary<B>(bin: B) -> Message where B: Into<Vec<u8>>
Create a new binary WebSocket message by converting to Vec
fn is_text(&self) -> bool
Indicates whether a message is a text message.
fn is_binary(&self) -> bool
Indicates whether a message is a binary message.
fn len(&self) -> usize
Get the length of the WebSocket message.
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.
fn into_data(self) -> Vec<u8>
Consume the WebSocket and return it as binary data.
fn into_text(self) -> Result<String>
Attempt to consume the WebSocket message and convert it to a String.
fn to_text(&self) -> Result<&str>
Attempt to get a &str from the WebSocket message, this will try to convert binary data to utf8.
Trait Implementations
impl Debug for Message
[src]
impl Eq for Message
[src]
impl PartialEq for Message
[src]
fn eq(&self, __arg_0: &Message) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Message) -> bool
This method tests for !=
.
impl Clone for Message
[src]
fn clone(&self) -> Message
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more