[−][src]Enum websocket::message::OwnedMessage
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
Text(String)A message containing UTF-8 text data
Binary(Vec<u8>)A message containing binary data
Close(Option<CloseData>)A message which indicates closure of the WebSocket connection. This message may or may not contain data.
Ping(Vec<u8>)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.
Pong(Vec<u8>)A pong message, sent in response to a Ping message, usually containing the same data as the received ping message.
Methods
impl OwnedMessage[src]
impl OwnedMessagepub fn is_close(&self) -> bool[src]
pub fn is_close(&self) -> boolChecks if this message is a close message.
assert!(OwnedMessage::Close(None).is_close());
pub fn is_control(&self) -> bool[src]
pub fn is_control(&self) -> boolChecks 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());
pub fn is_data(&self) -> bool[src]
pub fn is_data(&self) -> boolChecks 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());
pub fn is_ping(&self) -> bool[src]
pub fn is_ping(&self) -> boolChecks 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());
pub fn is_pong(&self) -> bool[src]
pub fn is_pong(&self) -> boolChecks 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]
impl DataFrame for OwnedMessagefn is_last(&self) -> bool[src]
fn is_last(&self) -> boolIs this dataframe the final dataframe of the message?
fn opcode(&self) -> u8[src]
fn opcode(&self) -> u8What type of data does this dataframe contain?
fn reserved(&self) -> &[bool; 3][src]
fn reserved(&self) -> &[bool; 3]Reserved bits of this dataframe
fn size(&self) -> usize[src]
fn size(&self) -> usizeHow long (in bytes) is this dataframe's payload
fn write_payload(&self, socket: &mut dyn Write) -> WebSocketResult<()>[src]
fn write_payload(&self, socket: &mut dyn Write) -> WebSocketResult<()>Write the payload to a writer
fn take_payload(self) -> Vec<u8>[src]
fn take_payload(self) -> Vec<u8>Takes the payload out into a vec
fn frame_size(&self, masked: bool) -> usize[src]
fn frame_size(&self, masked: bool) -> usizeGet's the size of the entire dataframe in bytes, i.e. header and payload. Read more
fn write_to(&self, writer: &mut dyn Write, mask: bool) -> WebSocketResult<()>[src]
fn write_to(&self, writer: &mut dyn Write, mask: bool) -> WebSocketResult<()>Writes a DataFrame to a Writer.
impl Message for OwnedMessage[src]
impl Message for OwnedMessagefn serialize(&self, writer: &mut dyn Write, masked: bool) -> WebSocketResult<()>[src]
fn serialize(&self, writer: &mut dyn Write, masked: bool) -> WebSocketResult<()>Attempt to form a message from a series of data frames
fn message_size(&self, masked: bool) -> usize[src]
fn message_size(&self, masked: bool) -> usizeReturns how many bytes this message will take up
fn from_dataframes<D>(frames: Vec<D>) -> WebSocketResult<Self> where
D: DataFrameTrait, [src]
fn from_dataframes<D>(frames: Vec<D>) -> WebSocketResult<Self> where
D: DataFrameTrait, Attempt to form a message from a series of data frames
impl PartialEq<OwnedMessage> for OwnedMessage[src]
impl PartialEq<OwnedMessage> for OwnedMessagefn eq(&self, other: &OwnedMessage) -> bool[src]
fn eq(&self, other: &OwnedMessage) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &OwnedMessage) -> bool[src]
fn ne(&self, other: &OwnedMessage) -> boolThis method tests for !=.
impl<'m> From<Message<'m>> for OwnedMessage[src]
impl<'m> From<Message<'m>> for OwnedMessageimpl<'m> From<OwnedMessage> for Message<'m>[src]
impl<'m> From<OwnedMessage> for Message<'m>fn from(message: OwnedMessage) -> Self[src]
fn from(message: OwnedMessage) -> SelfPerforms the conversion.
impl Clone for OwnedMessage[src]
impl Clone for OwnedMessagefn clone(&self) -> OwnedMessage[src]
fn clone(&self) -> OwnedMessageReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Eq for OwnedMessage[src]
impl Eq for OwnedMessageimpl Debug for OwnedMessage[src]
impl Debug for OwnedMessageAuto Trait Implementations
impl Send for OwnedMessage
impl Send for OwnedMessageimpl Sync for OwnedMessage
impl Sync for OwnedMessageBlanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 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]
impl<T> From for Timpl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 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]
impl<T> Typeable for T where
T: Any, impl<T> Erased for T[src]
impl<T> Erased for T