Struct websocket_base::dataframe::DataFrame
source · [−]pub struct DataFrame {
pub finished: bool,
pub reserved: [bool; 3],
pub opcode: Opcode,
pub data: Vec<u8>,
}
Expand description
Represents a WebSocket data frame.
The data held in a DataFrame is never masked. Masking/unmasking is done when sending and receiving the data frame,
This DataFrame, unlike the standard Message implementation (which also
implements the DataFrame trait), owns its entire payload. This means that calls to payload
don’t allocate extra memory (again unlike the default Message implementation).
Fields
finished: bool
Whether or no this constitutes the end of a message
reserved: [bool; 3]
The reserved portion of the data frame (RFC6455 5.2)
opcode: Opcode
The opcode associated with this data frame
data: Vec<u8>
The payload associated with this data frame
Implementations
sourceimpl DataFrame
impl DataFrame
sourcepub fn new(finished: bool, opcode: Opcode, data: Vec<u8>) -> DataFrame
pub fn new(finished: bool, opcode: Opcode, data: Vec<u8>) -> DataFrame
Creates a new DataFrame.
sourcepub fn read_dataframe_body(
header: DataFrameHeader,
body: Vec<u8>,
should_be_masked: bool
) -> WebSocketResult<Self>
pub fn read_dataframe_body(
header: DataFrameHeader,
body: Vec<u8>,
should_be_masked: bool
) -> WebSocketResult<Self>
Take the body and header of a dataframe and combine it into a single Dataframe struct. A websocket message can be made up of many individual dataframes, use the methods from the Message or OwnedMessage structs to take many of these and create a websocket message.
sourcepub fn read_dataframe<R>(
reader: &mut R,
should_be_masked: bool
) -> WebSocketResult<Self> where
R: Read,
pub fn read_dataframe<R>(
reader: &mut R,
should_be_masked: bool
) -> WebSocketResult<Self> where
R: Read,
Reads a DataFrame from a Reader.
sourcepub fn read_dataframe_with_limit<R>(
reader: &mut R,
should_be_masked: bool,
limit: usize
) -> WebSocketResult<Self> where
R: Read,
pub fn read_dataframe_with_limit<R>(
reader: &mut R,
should_be_masked: bool,
limit: usize
) -> WebSocketResult<Self> where
R: Read,
Reads a DataFrame from a Reader, or error out if header declares exceeding limit you specify
Trait Implementations
sourceimpl DataFrame for DataFrame
impl DataFrame for DataFrame
sourcefn write_payload(&self, socket: &mut dyn Write) -> WebSocketResult<()>
fn write_payload(&self, socket: &mut dyn Write) -> WebSocketResult<()>
Write the payload to a writer
sourcefn take_payload(self) -> Vec<u8>
fn take_payload(self) -> Vec<u8>
Takes the payload out into a vec
sourcefn frame_size(&self, masked: bool) -> usize
fn frame_size(&self, masked: bool) -> usize
Get’s the size of the entire dataframe in bytes, i.e. header and payload. Read more
impl StructuralPartialEq for DataFrame
Auto Trait Implementations
impl RefUnwindSafe for DataFrame
impl Send for DataFrame
impl Sync for DataFrame
impl Unpin for DataFrame
impl UnwindSafe for DataFrame
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more