[][src]Enum websocket::message::OwnedMessage

pub enum OwnedMessage {
    Text(String),
    Binary(Vec<u8>),
    Close(Option<CloseData>),
    Ping(Vec<u8>),
    Pong(Vec<u8>),
}

Represents an owned WebSocket message.

OwnedMessages are generated when the user receives a message (since the data has to be copied out of the network buffer anyway). If you would like to create a message out of borrowed data to use for sending please use the Message struct (which contains a Cow).

Note that OwnedMessage and Message can be converted into each other.

Variants

A message containing UTF-8 text data

A message containing binary data

A message which indicates closure of the WebSocket connection. This message may or may not contain data.

A ping message - should be responded to with a pong message. Usually the pong message will be sent with the same data as the received ping message.

A pong message, sent in response to a Ping message, usually containing the same data as the received ping message.

Methods

impl OwnedMessage
[src]

Checks if this message is a close message.

assert!(OwnedMessage::Close(None).is_close());

Checks if this message is a control message. Control messages are either Close, Ping, or Pong.

assert!(OwnedMessage::Ping(vec![]).is_control());
assert!(OwnedMessage::Pong(vec![]).is_control());
assert!(OwnedMessage::Close(None).is_control());

Checks if this message is a data message. Data messages are either Text or Binary.

assert!(OwnedMessage::Text("1337".to_string()).is_data());
assert!(OwnedMessage::Binary(vec![]).is_data());

Checks if this message is a ping message. Ping messages can come at any time and usually generate a Pong message response.

assert!(OwnedMessage::Ping("ping".to_string().into_bytes()).is_ping());

Checks if this message is a pong message. Pong messages are usually sent only in response to Ping messages.

assert!(OwnedMessage::Pong("pong".to_string().into_bytes()).is_pong());

Trait Implementations

impl DataFrame for OwnedMessage
[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 Message for OwnedMessage
[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 PartialEq<OwnedMessage> for OwnedMessage
[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 Clone for OwnedMessage
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Eq for OwnedMessage
[src]

impl Debug for OwnedMessage
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for OwnedMessage

impl Sync for OwnedMessage

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]