pub struct FrameHeader {
    pub is_final: bool,
    pub rsv1: bool,
    pub rsv2: bool,
    pub rsv3: bool,
    pub opcode: OpCode,
    pub mask: Option<[u8; 4]>,
}Expand description
A struct representing a WebSocket frame header.
Fields§
§is_final: boolIndicates that the frame is the last one of a possibly fragmented message.
rsv1: boolReserved for protocol extensions.
rsv2: boolReserved for protocol extensions.
rsv3: boolReserved for protocol extensions.
opcode: OpCodeWebSocket protocol opcode.
mask: Option<[u8; 4]>A frame mask, if any.
Implementations§
Source§impl FrameHeader
 
impl FrameHeader
Sourcepub(crate) const MAX_SIZE: usize = 14usize
 
pub(crate) const MAX_SIZE: usize = 14usize
The longest possible header is 14 bytes, which would represent a message sent from the client to the server with a payload greater than 64KB.
Sourcepub fn parse(
    cursor: &mut Cursor<impl AsRef<[u8]>>,
) -> Result<Option<(Self, u64)>>
 
pub fn parse( cursor: &mut Cursor<impl AsRef<[u8]>>, ) -> Result<Option<(Self, u64)>>
Parse a header from an input stream.
Returns None if insufficient data and does not consume anything in this case.
Payload size is returned along with the header.
Sourcepub fn len(&self, length: u64) -> usize
 
pub fn len(&self, length: u64) -> usize
Get the size of the header formatted with given payload length.
Sourcepub fn format(&self, length: u64, output: &mut impl Write) -> Result<()>
 
pub fn format(&self, length: u64, output: &mut impl Write) -> Result<()>
Format a header for given payload size.
Sourcepub(crate) fn set_random_mask(&mut self)
 
pub(crate) fn set_random_mask(&mut self)
Generate a random frame mask and store this in the header.
Of course this does not change frame contents. It just generates a mask.
Source§impl FrameHeader
 
impl FrameHeader
Trait Implementations§
Source§impl Clone for FrameHeader
 
impl Clone for FrameHeader
Source§fn clone(&self) -> FrameHeader
 
fn clone(&self) -> FrameHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read more