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§
Source§impl 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