Struct websocket::dataframe::DataFrame
[−]
[src]
pub struct DataFrame { pub finished: bool, pub reserved: [bool; 3], pub opcode: Opcode, pub data: Vec<u8>, }
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
Methods
impl DataFrame
[src]
fn new(finished: bool, opcode: Opcode, data: Vec<u8>) -> DataFrame
Creates a new DataFrame.
fn read_dataframe<R>(reader: &mut R,
should_be_masked: bool)
-> WebSocketResult<Self> where R: Read
should_be_masked: bool)
-> WebSocketResult<Self> where R: Read
Reads a DataFrame from a Reader.
Trait Implementations
impl Debug for DataFrame
[src]
impl Clone for DataFrame
[src]
fn clone(&self) -> DataFrame
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for DataFrame
[src]
fn eq(&self, __arg_0: &DataFrame) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &DataFrame) -> bool
This method tests for !=
.
impl DataFrameable for DataFrame
[src]
fn is_last(&self) -> bool
Is this dataframe the final dataframe of the message?
fn opcode(&self) -> u8
What type of data does this dataframe contain?
fn reserved<'a>(&'a self) -> &'a [bool; 3]
Reserved bits of this dataframe
fn payload<'a>(&'a self) -> Cow<'a, [u8]>
Entire payload of the dataframe. If not known then implement write_payload as that is the actual method used when sending the dataframe over the wire. Read more
fn size(&self) -> usize
How long (in bytes) is this dataframe's payload
fn write_payload<W>(&self, socket: &mut W) -> WebSocketResult<()> where W: Write
Write the payload to a writer
fn write_to<W>(&self, writer: &mut W, mask: bool) -> WebSocketResult<()> where W: Write
Writes a DataFrame to a Writer.