[−][src]Enum websocket_base::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
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]
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 DataFrame for OwnedMessage
[src]
fn is_last(&self) -> bool
[src]
fn opcode(&self) -> u8
[src]
fn reserved(&self) -> &[bool; 3]
[src]
fn size(&self) -> usize
[src]
fn write_payload(&self, socket: &mut dyn Write) -> WebSocketResult<()>
[src]
fn take_payload(self) -> Vec<u8>
[src]
fn frame_size(&self, masked: bool) -> usize
[src]
fn write_to(&self, writer: &mut dyn Write, mask: bool) -> WebSocketResult<()>
[src]
impl Message for OwnedMessage
[src]
fn serialize(&self, writer: &mut dyn Write, masked: bool) -> WebSocketResult<()>
[src]
Attempt to form a message from a series of data frames
fn message_size(&self, masked: bool) -> usize
[src]
Returns how many bytes this message will take up
fn from_dataframes<D>(frames: Vec<D>) -> WebSocketResult<Self> where
D: DataFrameTrait,
[src]
D: DataFrameTrait,
Attempt to form a message from a series of data frames
impl From<String> for OwnedMessage
[src]
impl From<Vec<u8>> for OwnedMessage
[src]
impl<'m> From<Message<'m>> for OwnedMessage
[src]
impl<'m> From<OwnedMessage> for Message<'m>
[src]
fn from(message: OwnedMessage) -> Self
[src]
impl Clone for OwnedMessage
[src]
fn clone(&self) -> OwnedMessage
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Eq for OwnedMessage
[src]
impl PartialEq<OwnedMessage> for OwnedMessage
[src]
fn eq(&self, other: &OwnedMessage) -> bool
[src]
fn ne(&self, other: &OwnedMessage) -> bool
[src]
impl Debug for OwnedMessage
[src]
impl StructuralPartialEq for OwnedMessage
[src]
impl StructuralEq for OwnedMessage
[src]
Auto Trait Implementations
impl Send for OwnedMessage
impl Sync for OwnedMessage
impl Unpin for OwnedMessage
impl UnwindSafe for OwnedMessage
impl RefUnwindSafe for OwnedMessage
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,