Skip to main content

MessageHeader

Enum MessageHeader 

Source
#[non_exhaustive]
pub enum MessageHeader { Type0 { timestamp: u32, message_length: u32, message_type_id: u8, message_stream_id: u32, }, Type1 { timestamp_delta: u32, message_length: u32, message_type_id: u8, }, Type2 { timestamp_delta: u32, }, Type3, }
Expand description

Chunk Message Header: one of 4 formats selected by Fmt (§5.3.1.2), carrying decreasing field sets — each format after Type 0 inherits the fields it omits from the preceding chunk on the same chunk stream.

Reassembling that “preceding chunk” state (so Type 1/2/3 headers can be resolved to absolute values) is a stateful job for the chunk-stream reassembler (#738 Task 4), not this header type. In particular, a Type 3 header carrying zero bytes here does not by itself tell you whether an Extended Timestamp follows it on the wire: per §5.3.1.3, a Type 3 chunk carries the 4-byte Extended Timestamp when — and only when — the most recent Type 0/1/2 chunk on the same csid itself used one. Deciding that requires exactly that per-csid state, so MessageHeader::parse never consumes an Extended Timestamp for Fmt::Type3; the reassembler must apply this rule itself once it is tracking that state.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Type0

Type 0 (§5.3.1.2.1, 11 bytes on the wire before any Extended Timestamp). MUST be used at the start of a chunk stream and whenever the stream timestamp goes backward.

Fields

§timestamp: u32

Absolute timestamp of the message (already resolved from any Extended Timestamp).

§message_length: u32

Length in bytes of the whole message (not the chunk payload).

§message_type_id: u8

Message type id (§6/§7.1).

§message_stream_id: u32

Message stream id. The wire encoding of this field alone is little-endian (§5.3.1.2.1).

§

Type1

Type 1 (§5.3.1.2.2, 7 bytes before any Extended Timestamp). No message stream id — inherits the preceding chunk’s.

Fields

§timestamp_delta: u32

Delta from the previous chunk’s timestamp on this csid (already resolved from any Extended Timestamp).

§message_length: u32

Length in bytes of the whole message.

§message_type_id: u8

Message type id (§6/§7.1).

§

Type2

Type 2 (§5.3.1.2.3, 3 bytes before any Extended Timestamp). Neither stream id nor message length included — both inherited.

Fields

§timestamp_delta: u32

Delta from the previous chunk’s timestamp on this csid (already resolved from any Extended Timestamp).

§

Type3

Type 3 (§5.3.1.2.4, 0 bytes). Stream id, message length, message type id, and timestamp delta are all inherited from the preceding chunk on the same csid.

Implementations§

Source§

impl MessageHeader

Source

pub fn parse(fmt: Fmt, bytes: &[u8]) -> Result<(Self, usize), RtmpError>

Parse the message header that follows a BasicHeader carrying fmt. Returns the parsed variant and the number of bytes consumed from bytes — the fixed per-fmt header length, plus 4 more if a Type 0/1/2 field’s 24-bit value read exactly EXTENDED_TIMESTAMP_MARKER (in which case the real, unresolved value is read from the following 4-byte big-endian Extended Timestamp — see §5.3.1.3).

§Errors

RtmpError::BufferTooShort if bytes does not hold the full fixed header (and, when signalled, the Extended Timestamp).

Trait Implementations§

Source§

impl Clone for MessageHeader

Source§

fn clone(&self) -> MessageHeader

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 MessageHeader

Source§

impl Debug for MessageHeader

Source§

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

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

impl Eq for MessageHeader

Source§

impl PartialEq for MessageHeader

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for MessageHeader

Source§

type Error = RtmpError

The error type this implementer returns (usually the same as the corresponding Parse impl, but need not be).
Source§

fn serialized_len(&self) -> usize

Number of bytes serialize_into will write.
Source§

fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, RtmpError>

Write the serialised form into buf. Returns the number of bytes written (always equal to serialized_len()).
Source§

fn to_bytes(&self) -> Vec<u8>
where Self::Error: Debug,

Convenience: allocate a Vec and serialise into it. Read more
Source§

impl StructuralPartialEq for MessageHeader

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