Struct evzht9h3nznqzwl::message::Message [] [src]

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]

[src]

Create a new WebSocket message with text data

[src]

Create a new WebSocket message with binary data

[src]

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

[src]

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.

[src]

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

[src]

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

[src]

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> Eq for Message<'a>
[src]

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

[src]

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

[src]

This method tests for !=.

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[src]

Formats the value using the given formatter.

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

[src]

Is this dataframe the final dataframe of the message?

[src]

What type of data does this dataframe contain?

[src]

Reserved bits of this dataframe

[src]

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

[src]

Write the payload to a writer

[src]

Takes the payload out into a vec

[src]

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

[src]

Writes a DataFrame to a Writer.

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

[src]

Attempt to form a message from a series of data frames

[src]

Returns how many bytes this message will take up

[src]

Attempt to form a message from a series of data frames

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

[src]

Performs the conversion.