Enum parity_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

Implementations

impl Message[src]

pub fn text<S>(string: S) -> Message where
    S: Into<String>, 
[src]

Create a new text WebSocket message from a stringable.

pub fn binary<B>(bin: B) -> Message where
    B: Into<Vec<u8>>, 
[src]

Create a new binary WebSocket message by converting to Vec.

pub fn is_text(&self) -> bool[src]

Indicates whether a message is a text message.

pub fn is_binary(&self) -> bool[src]

Indicates whether a message is a binary message.

pub fn len(&self) -> usize[src]

Get the length of the WebSocket message.

pub fn is_empty(&self) -> bool[src]

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_data(self) -> Vec<u8>

Notable traits for Vec<u8, A>

impl<A> Write for Vec<u8, A> where
    A: Allocator
[src]

Consume the WebSocket and return it as binary data.

pub fn into_text(self) -> Result<String>[src]

Attempt to consume the WebSocket message and convert it to a String.

pub fn as_text(&self) -> Result<&str>[src]

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]

impl Debug for Message[src]

impl Display for Message[src]

impl Eq for Message[src]

impl<'b> From<&'b [u8]> for Message[src]

impl<'s> From<&'s str> for Message[src]

impl From<String> for Message[src]

impl From<Vec<u8, Global>> for Message[src]

impl PartialEq<Message> for Message[src]

impl StructuralEq for Message[src]

impl StructuralPartialEq for Message[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]