[][src]Struct websocket::message::Message

pub struct Message<'a> {
    pub opcode: Type,
    pub cd_status_code: Option<u16>,
    pub payload: Cow<'a, [u8]>,
}

Represents a WebSocket message.

This message also has the ability to not own its payload, and stores its entire payload in chunks that get written in order when the message gets sent. This makes the write_payload allocate less memory than the payload method (which creates a new buffer every time).

Incidentally this (the default implementation of Message) implements the DataFrame trait because this message just gets sent as one single DataFrame.

Fields

Type of WebSocket message

Optional status code to send when closing a connection. (only used if this message is of Type::Close)

Main payload

Methods

impl<'a> Message<'a>
[src]

Create a new WebSocket message with text data

Create a new WebSocket message with binary data

Create a new WebSocket message that signals the end of a WebSocket connection, although messages can still be sent after sending this

Create a new WebSocket message that signals the end of a WebSocket connection and provide a text reason and a status code for why. Messages can still be sent after sending this message.

Create a ping WebSocket message, a pong is usually sent back after sending this with the same data

Create a pong WebSocket message, usually a response to a ping message

Convert a ping message to a pong, keeping the data. This will fail if the original message is not a ping.

Trait Implementations

impl<'a> DataFrame for Message<'a>
[src]

Is this dataframe the final dataframe of the message?

What type of data does this dataframe contain?

Reserved bits of this dataframe

How long (in bytes) is this dataframe's payload

Write the payload to a writer

Important traits for Vec<u8>

Takes the payload out into a vec

Get's the size of the entire dataframe in bytes, i.e. header and payload. Read more

Writes a DataFrame to a Writer.

impl<'a> Message for Message<'a>
[src]

Attempt to form a message from a series of data frames

Returns how many bytes this message will take up

Attempt to form a message from a series of data frames

impl<'a> PartialEq<Message<'a>> for Message<'a>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'m> From<Message<'m>> for OwnedMessage
[src]

Performs the conversion.

impl<'m> From<OwnedMessage> for Message<'m>
[src]

Performs the conversion.

impl<'a> Clone for Message<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> Eq for Message<'a>
[src]

impl<'a> Debug for Message<'a>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> Send for Message<'a>

impl<'a> Sync for Message<'a>

Blanket Implementations

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

Performs the conversion.

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

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> From for T
[src]

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.

impl<T> Erased for T
[src]