Trait websocket::ws::dataframe::DataFrame [] [src]

pub trait 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 { ... }
}

A generic DataFrame. Every dataframe should be able to provide these methods. (If the payload is not known in advance then rewrite the write_payload method)

Required Methods

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.

Provided Methods

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.

Implementors