pub struct StreamFrame {
pub stream_id: StreamId,
pub sequence: u64,
pub data: Vec<u8>,
pub flags: u8,
pub timestamp: u64,
}Expand description
A framed unit of data for one logical stream.
§Wire format (little-endian)
[stream_id: u32 LE][sequence_num: u64 LE][payload_len: u32 LE][flags: u8][timestamp: u64 LE][payload...]Fields§
§stream_id: StreamIdWhich stream this frame belongs to.
sequence: u64Monotonically increasing per-stream sequence number.
data: Vec<u8>Payload bytes.
flags: u8§timestamp: u64Wall-clock timestamp at the time the frame was created (caller-supplied).
Implementations§
Source§impl StreamFrame
impl StreamFrame
Sourcepub fn is_control(&self) -> bool
pub fn is_control(&self) -> bool
Returns true if this is a pure control frame (no payload bytes matter).
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encode the frame into a Vec<u8> using the fixed wire format.
Wire layout (all little-endian):
stream_id(4) + sequence_num(8) + payload_len(4) + flags(1) + timestamp(8) + payload
Total header: 25 bytes.
Sourcepub fn decode(data: &[u8]) -> Result<Self, MuxError>
pub fn decode(data: &[u8]) -> Result<Self, MuxError>
Decode a frame from a byte slice produced by StreamFrame::encode.
§Errors
Returns MuxError::FrameTooLarge if data is shorter than the
minimum header size or shorter than the declared payload length.
Trait Implementations§
Source§impl Clone for StreamFrame
impl Clone for StreamFrame
Source§fn clone(&self) -> StreamFrame
fn clone(&self) -> StreamFrame
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamFrame
impl RefUnwindSafe for StreamFrame
impl Send for StreamFrame
impl Sync for StreamFrame
impl Unpin for StreamFrame
impl UnsafeUnpin for StreamFrame
impl UnwindSafe for StreamFrame
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more