pub struct TsPacket<'a> {
pub header: TsHeader,
pub payload: Option<&'a [u8]>,
pub raw: &'a [u8; 188],
/* private fields */
}Expand description
Borrowed view into one 188-byte TS packet.
Serde: Serialize-only (re-parse from wire bytes to reconstruct). raw is
excluded from the serialized form because it is redundant once the header
has been parsed.
Fields§
§header: TsHeaderParsed header fields.
payload: Option<&'a [u8]>Slice into the packet’s payload, or None when has_payload == false
or the adaptation field consumed the whole packet body.
raw: &'a [u8; 188]The raw 188 bytes of the packet — kept for cheap forwarding.
Implementations§
Source§impl<'a> TsPacket<'a>
impl<'a> TsPacket<'a>
Sourcepub fn parse(buf: &'a [u8]) -> Result<Self>
pub fn parse(buf: &'a [u8]) -> Result<Self>
Parse a single 188-byte TS packet from a buffer.
Returns Err(Error::InvalidSyncByte) if the first byte is not 0x47,
Err(Error::BufferTooShort) if fewer than 188 bytes, or Ok with
the parsed packet otherwise.
Sourcepub fn adaptation_field(&self) -> Option<Result<AdaptationField>>
pub fn adaptation_field(&self) -> Option<Result<AdaptationField>>
Decode the adaptation field, if present.
Returns None when the packet carries no adaptation field, and
Some(Err(..)) when a present field is truncated. Layout per
ISO/IEC 13818-1:2007 §2.4.3.4 (docs/iso_13818_1_systems.md).