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

source

pub fn new(finished: bool, opcode: Opcode, data: Vec<u8>) -> DataFrame

Creates a new DataFrame.

source

pub fn read_dataframe_body( header: DataFrameHeader, body: Vec<u8>, should_be_masked: bool ) -> Result<DataFrame, WebSocketError>

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.

source

pub fn read_dataframe<R>( reader: &mut R, should_be_masked: bool ) -> Result<DataFrame, WebSocketError>
where R: Read,

Reads a DataFrame from a Reader.

source

pub fn read_dataframe_with_limit<R>( reader: &mut R, should_be_masked: bool, limit: usize ) -> Result<DataFrame, WebSocketError>
where R: Read,

Reads a DataFrame from a Reader, or error out if header declares exceeding limit you specify

Trait Implementations§

source§

impl Clone for DataFrame

source§

fn clone(&self) -> DataFrame

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl DataFrame for DataFrame

source§

fn is_last(&self) -> bool

Is this dataframe the final dataframe of the message?
source§

fn opcode(&self) -> u8

What type of data does this dataframe contain?
source§

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

Reserved bits of this dataframe
source§

fn size(&self) -> usize

How long (in bytes) is this dataframe’s payload
source§

fn write_payload(&self, socket: &mut dyn Write) -> Result<(), WebSocketError>

Write the payload to a writer
source§

fn take_payload(self) -> Vec<u8>

Takes the payload out into a vec
source§

fn frame_size(&self, masked: bool) -> usize

Get’s the size of the entire dataframe in bytes, i.e. header and payload.
source§

fn write_to( &self, writer: &mut dyn Write, mask: bool ) -> Result<(), WebSocketError>

Writes a DataFrame to a Writer.
source§

impl Debug for DataFrame

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl PartialEq for DataFrame

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for DataFrame

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Typeable for T
where T: Any,

source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.