pub struct Pid(/* private fields */);Expand description
A 13-bit MPEG-TS Packet Identifier.
Thin newtype over the wire u16. Values are masked to 13 bits on
construction (0x0000..=0x1FFF), matching the transport header field
width (ISO/IEC 13818-1 §2.4.3.2).
Implementations§
Source§impl Pid
impl Pid
Sourcepub const fn from_wire_masked(value: u16) -> Self
pub const fn from_wire_masked(value: u16) -> Self
Construct a Pid from the low 13 bits of value, deliberately
discarding the rest: the explicit name for extracting the 13-bit PID
field out of a wider wire word (e.g. reserved(3) + PID(13)), where
masking is the specified behaviour. Identical to Pid::new; prefer
this at parse sites so the intent is visible and a caller-supplied
value is never masked by accident (use Pid::try_new for those).
use mpeg_ts::pid::Pid;
// reserved(3) = 0b111 followed by PID 0x0100.
assert_eq!(Pid::from_wire_masked(0xE100).value(), 0x0100);
assert_eq!(Pid::try_new(0xE100).unwrap_err().value, 0xE100);Sourcepub const fn try_new(value: u16) -> Result<Self, PidOutOfRange>
pub const fn try_new(value: u16) -> Result<Self, PidOutOfRange>
Construct a Pid, rejecting any value above Pid::MASK (0x1FFF).
Use this at API boundaries that take a caller-supplied value; use
Pid::new only where the bits are already masked by the wire format.
§Errors
PidOutOfRange when value > 0x1FFF.