Skip to main content

StreamHeader

Struct StreamHeader 

Source
pub struct StreamHeader {
    pub stream_id: u16,
    pub flags: StreamFlags,
    pub reserved: u8,
    pub length: u32,
}
Expand description

Stream header for multiplexing

Format (8 bytes):

  • stream_id: u16 (0 = control, 1-65535 = data streams)
  • flags: u8 (FIN=1, RST=2, ACK=4, SYN=8)
  • reserved: u8
  • length: u32 (payload length, big-endian)

Fields§

§stream_id: u16

Stream ID (0 = control, 1-65535 = data streams)

§flags: StreamFlags

Flags: FIN=1, RST=2, ACK=4, SYN=8

§reserved: u8

Reserved for future use

§length: u32

Payload length

Implementations§

Source§

impl StreamHeader

Source

pub const CONTROL_STREAM: u16 = 0

Control stream ID

Source

pub const MAX_STREAM_ID: u16 = 65535

Maximum stream ID

Source

pub fn new(stream_id: u16, flags: StreamFlags, length: u32) -> Self

Create a new stream header

Source

pub fn data(stream_id: u16, length: u32) -> Self

Create a data header

Source

pub fn syn(stream_id: u16) -> Self

Create a SYN header (open stream)

Source

pub fn fin(stream_id: u16) -> Self

Create a FIN header (close stream)

Source

pub fn rst(stream_id: u16) -> Self

Create a RST header (reset stream)

Source

pub fn ack(stream_id: u16) -> Self

Create an ACK header

Source

pub fn is_control(&self) -> bool

Check if this is a control stream message

Source

pub fn encode(&self, dst: &mut BytesMut)

Encode header to bytes

Source

pub fn to_bytes(&self) -> Bytes

Encode header to a new BytesMut

Source

pub fn decode(src: &[u8]) -> Option<Self>

Decode header from bytes

Source

pub fn decode_from(src: &mut BytesMut) -> Option<Self>

Decode header from BytesMut, advancing the buffer

Source

pub fn frame_size(&self) -> usize

Total frame size (header + payload)

Trait Implementations§

Source§

impl Clone for StreamHeader

Source§

fn clone(&self) -> StreamHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for StreamHeader

Source§

impl Debug for StreamHeader

Source§

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

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

impl Eq for StreamHeader

Source§

impl PartialEq for StreamHeader

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for StreamHeader

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V