Frame

Struct Frame 

Source
pub struct Frame {
    pub message: Message,
    /* private fields */
}
Expand description

Frame structure from websockets connection

Fields§

§message: Message

Inner message

Implementations§

Source§

impl Frame

Source

pub const FIN_RSV: u8 = 128u8

FIN RSV bytes

Source

pub const OP_CODE_CONTINUATION: u8 = 0u8

Operation code for a continuation request

Source

pub const OP_CODE_TEXT: u8 = 1u8

Operation code for a text message

Source

pub const OP_CODE_BINARY: u8 = 2u8

Operation code for a binary message

Source

pub const OP_CODE_CLOSE: u8 = 8u8

Operation code for a close request message

Source

pub const OP_CODE_PING: u8 = 9u8

Operation code for a ping message

Source

pub const OP_CODE_PONG: u8 = 10u8

Operation code for a pong message

Source

pub fn op_code(&self) -> u8

Returns the OP CODE of the frame as a u8, where the last 4 bits contain the OP CODE

Source

pub fn parse<A: AsRef<[u8]>>(content: A) -> Result<Frame, FrameParseError>

Attempts to parse a frame from a stream of bytes

Source

pub fn text<A: Into<String>>(text: A) -> Frame

Creates a text frame

Source

pub fn ping<A: Into<Vec<u8>>>(payload: A) -> Frame

Creates a ping message with the given application data

Source

pub fn pong<A: Into<Vec<u8>>>(payload: A) -> Frame

Creates a pong message with the given application data

Source

pub fn binary<A: Into<Vec<u8>>>(binary: A) -> Frame

Creates a binary frame

Source

pub fn close() -> Frame

Creates a close frame

Source

pub fn get_message(&self) -> &Message

Takes the frame and returns the contained message, if any

Source

pub fn is_close(&self) -> bool

Indicates if this frame is a closing frame

Trait Implementations§

Source§

impl From<Frame> for Message

Source§

fn from(source: Frame) -> Message

Converts to this type from the input type.
Source§

impl From<Frame> for Vec<u8>

Source§

fn from(source: Frame) -> Vec<u8>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.