[−][src]Enum websockets::Frame
Data which is sent and received through the WebSocket connection.
Sending
To send a Frame
, you can construct it normally and use the WebSocket::send()
method,
or use the convenience methods for each frame type
(send_text()
, send_binary()
,
close()
, send_ping()
,
and send_pong()
).
Receiving
Frame
s can be received through the WebSocket::receive()
method.
To extract the underlying data from a received Frame
,
you can use the convenience methods as_text()
,
as_binary()
, as_close()
,
as_ping()
, and as_pong()
.
(and their mut
counterparts), or simply match
.
Variants
A Text frame
Fields of Text
A Binary frame
Fields of Binary
A Close frame
A Ping frame
A Pong frame
Implementations
impl Frame
[src]
pub fn is_text(&self) -> bool
[src]
Returns whether the frame is a Text frame.
pub fn as_text(&self) -> Option<(&String, &bool, &bool)>
[src]
Attempts to interpret the frame as a Text frame, returning a reference to the underlying data if it is, and None otherwise.
pub fn as_text_mut(&mut self) -> Option<(&mut String, &mut bool, &mut bool)>
[src]
Attempts to interpret the frame as a Text frame, returning a mutable reference to the underlying data if it is, and None otherwise.
pub fn is_binary(&self) -> bool
[src]
Returns whether the frame is a Binary frame.
pub fn as_binary(&self) -> Option<(&Vec<u8>, &bool, &bool)>
[src]
Attempts to interpret the frame as a Binary frame, returning a reference to the underlying data if it is, and None otherwise.
pub fn as_binary_mut(&mut self) -> Option<(&mut Vec<u8>, &mut bool, &mut bool)>
[src]
Attempts to interpret the frame as a Binary frame, returning a mutable reference to the underlying data if it is, and None otherwise.
pub fn is_close(&self) -> bool
[src]
Returns whether the frame is a Close frame.
pub fn as_close(&self) -> Option<&(u16, String)>
[src]
Attempts to interpret the frame as a Close frame, returning a reference to the underlying data if it is, and None otherwise.
pub fn as_close_mut(&mut self) -> Option<&mut (u16, String)>
[src]
Attempts to interpret the frame as a Close frame, returning a mutable reference to the underlying data if it is, and None otherwise.
pub fn is_ping(&self) -> bool
[src]
Returns whether the frame is a Ping frame.
pub fn as_ping(&self) -> Option<&Vec<u8>>
[src]
Attempts to interpret the frame as a Ping frame, returning a reference to the underlying data if it is, and None otherwise.
pub fn as_ping_mut(&mut self) -> Option<&mut Vec<u8>>
[src]
Attempts to interpret the frame as a Ping frame, returning a mutable reference to the underlying data if it is, and None otherwise.
pub fn is_pong(&self) -> bool
[src]
Returns whether the frame is a Pong frame.
pub fn as_pong(&self) -> Option<&Vec<u8>>
[src]
Attempts to interpret the frame as a Pong frame, returning a reference to the underlying data if it is, and None otherwise.
pub fn as_pong_mut(&mut self) -> Option<&mut Vec<u8>>
[src]
Attempts to interpret the frame as a Pong frame, returning a mutable reference to the underlying data if it is, and None otherwise.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,