#[non_exhaustive]pub struct AdaptationField<'a> {
pub discontinuity_indicator: bool,
pub random_access_indicator: bool,
pub elementary_stream_priority_indicator: bool,
pub pcr: Option<Pcr>,
pub opcr: Option<Pcr>,
pub splice_countdown: Option<i8>,
pub transport_private_data: Option<&'a [u8]>,
pub extension: Option<AdaptationFieldExtension<'a>>,
pub pcr_reserved: u8,
pub opcr_reserved: u8,
pub stuffing: &'a [u8],
}Expand description
Decoded adaptation field — full §2.4.3.4 layout including transport-private data and the adaptation-field extension sub-structure.
The transport_private_data slice borrows from the original packet buffer
(it is genuinely opaque caller-defined bytes per the spec — &[u8] is the
correct public type). All other fields are fully typed.
ISO/IEC 13818-1:2007 §2.4.3.4.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.discontinuity_indicator: boolA timing/continuity discontinuity starts at this packet.
random_access_indicator: boolThis packet is a random-access point.
elementary_stream_priority_indicator: boolElementary-stream priority hint.
pcr: Option<Pcr>Program Clock Reference, present iff the PCR flag is set.
opcr: Option<Pcr>Original PCR, present iff the OPCR flag is set.
splice_countdown: Option<i8>Splice countdown (packets until the splice point), iff the flag is set.
transport_private_data: Option<&'a [u8]>Opaque transport-private data (caller-defined; &[u8] is spec-correct here).
Present iff transport_private_data_flag is set in the flags byte
(ISO/IEC 13818-1:2007 §2.4.3.4).
extension: Option<AdaptationFieldExtension<'a>>Typed adaptation-field extension sub-structure, if the flag is set.
pcr_reserved: u8The 6 reserved bits between program_clock_reference_base and
program_clock_reference_extension of the PCR (Table 2-6; spec
convention 0b111111). Real streams (e.g. TSDuck’s test-002.ts)
carry 0, so the value is kept for a byte-exact round trip. Only
meaningful when pcr is Some.
opcr_reserved: u8The 6 reserved bits of the OPCR (same layout as pcr_reserved).
stuffing: &'a [u8]The stuffing bytes that pad the adaptation-field body out to its
declared adaptation_field_length (ISO/IEC 13818-1 Table 2-6 —
“stuffing_byte: fixed 8-bit value 0xFF”).
Real encoders pad the adaptation field so the packet payload begins at a
fixed offset; these bytes are part of the wire image. They are kept
verbatim (not just counted) so a non-0xFF filler from a
non-conforming encoder also round-trips byte-for-byte. Use &[] when
constructing an adaptation field with no stuffing.
Implementations§
Source§impl<'a> AdaptationField<'a>
impl<'a> AdaptationField<'a>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
An adaptation field with every flag clear, no optional fields, no
stuffing and spec-convention reserved bits (all 1). Set fields on the
result (the struct is #[non_exhaustive]).
Sourcepub fn serialized_len(&self) -> usize
pub fn serialized_len(&self) -> usize
Number of bytes written by serialize_into.
This is the body length excluding the leading adaptation_field_length
byte — it is the value carried in that length byte itself
(ISO/IEC 13818-1:2007 §2.4.3.4).
Sourcepub fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
pub fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
Serialize the adaptation field into buf.
Writes the body bytes — the flags byte plus optional fields in the
order specified by ISO/IEC 13818-1:2007 §2.4.3.4. The
adaptation_field_length byte itself is not written here; the caller
must prepend it (it equals serialized_len()).
Returns the number of bytes written on success, or
Error::OutputBufferTooSmall if buf is shorter than
serialized_len().
Trait Implementations§
Source§impl<'a> Clone for AdaptationField<'a>
impl<'a> Clone for AdaptationField<'a>
Source§impl<'a> Debug for AdaptationField<'a>
impl<'a> Debug for AdaptationField<'a>
Source§impl Default for AdaptationField<'_>
impl Default for AdaptationField<'_>
impl<'a> Eq for AdaptationField<'a>
Source§impl<'a> PartialEq for AdaptationField<'a>
impl<'a> PartialEq for AdaptationField<'a>
Source§impl<'a> Serialize for AdaptationField<'a>
Available on crate feature serde only.
impl<'a> Serialize for AdaptationField<'a>
serde only.