Enum ws::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 len(&self) -> usize
Get the length of the WebSocket message.
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 as_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 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
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 !=
.