Enum websocket::OwnedMessage [−][src]
pub enum OwnedMessage { Text(String), Binary(Vec<u8, Global>), Close(Option<CloseData>), Ping(Vec<u8, Global>), Pong(Vec<u8, Global>), }
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
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.
Implementations
impl OwnedMessage
[src][−]
pub fn is_close(&self) -> bool
[src][−]
Checks if this message is a close message.
assert!(OwnedMessage::Close(None).is_close());
pub fn is_control(&self) -> bool
[src][−]
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][−]
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][−]
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][−]
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 Clone for OwnedMessage
[src][+]
impl DataFrame for OwnedMessage
[src][+]
impl Debug for OwnedMessage
[src][+]
impl Eq for OwnedMessage
[src]
impl<'m> From<Message<'m>> for OwnedMessage
[src][+]
impl<'m> From<OwnedMessage> for Message<'m>
[src][+]
impl From<String> for OwnedMessage
[src][+]
impl From<Vec<u8, Global>> for OwnedMessage
[src][+]
impl Message for OwnedMessage
[src][+]
impl PartialEq<OwnedMessage> for OwnedMessage
[src][+]
impl StructuralEq for OwnedMessage
[src]
impl StructuralPartialEq for OwnedMessage
[src]
Auto Trait Implementations
impl RefUnwindSafe for OwnedMessage
impl Send for OwnedMessage
impl Sync for OwnedMessage
impl Unpin for OwnedMessage
impl UnwindSafe for OwnedMessage
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<T> Typeable for T where
T: Any,
[+]
T: Any,