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

Whether or no this constitutes the end of a message

reserved

The reserved portion of the data frame (RFC6455 5.2)

opcode

The opcode associated with this data frame

data

The payload associated with this data frame

Methods

impl DataFrame

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

Reads a DataFrame from a Reader.

Trait Implementations

impl DataFrameable for DataFrame

fn is_last(&self) -> bool

fn opcode(&self) -> u8

fn reserved<'a>(&'a self) -> &'a [bool; 3]

fn payload<'a>(&'a self) -> Cow<'a, [u8]>

fn size(&self) -> usize

fn write_payload<W>(&self, socket: &mut W) -> WebSocketResult<()> where W: Write

fn write_to<W>(&self, writer: &mut W, mask: bool) -> WebSocketResult<()> where W: Write

Derived Implementations

impl PartialEq for DataFrame

fn eq(&self, __arg_0: &DataFrame) -> bool

fn ne(&self, __arg_0: &DataFrame) -> bool

impl Clone for DataFrame

fn clone(&self) -> DataFrame

1.0.0fn clone_from(&mut self, source: &Self)

impl Debug for DataFrame

fn fmt(&self, __arg_0: &mut Formatter) -> Result