[−][src]Enum websocket::message::OwnedMessage
Represents an owned WebSocket message.
OwnedMessage
s 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 OwnedMessage
pub fn is_close(&self) -> bool
[src]
[−]
pub fn is_close(&self) -> bool
Checks 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) -> bool
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());
pub fn is_data(&self) -> bool
[src]
[−]
pub fn is_data(&self) -> bool
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());
pub fn is_ping(&self) -> bool
[src]
[−]
pub fn is_ping(&self) -> bool
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());
pub fn is_pong(&self) -> bool
[src]
[−]
pub fn is_pong(&self) -> bool
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]
[+]
impl DataFrame for OwnedMessage
impl Message for OwnedMessage
[src]
[+]
impl Message for OwnedMessage
impl PartialEq<OwnedMessage> for OwnedMessage
[src]
[+]
impl PartialEq<OwnedMessage> for OwnedMessage
impl<'m> From<Message<'m>> for OwnedMessage
[src]
[+]
impl<'m> From<Message<'m>> for OwnedMessage
impl<'m> From<OwnedMessage> for Message<'m>
[src]
[+]
impl<'m> From<OwnedMessage> for Message<'m>
impl Clone for OwnedMessage
[src]
[+]
impl Clone for OwnedMessage
impl Eq for OwnedMessage
[src]
impl Eq for OwnedMessage
impl Debug for OwnedMessage
[src]
[+]
impl Debug for OwnedMessage
Auto Trait Implementations
impl Send for OwnedMessage
impl Send for OwnedMessage
impl Sync for OwnedMessage
impl Sync for OwnedMessage
Blanket 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) -> T
Creates 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 T
impl<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 T
Mutably 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