pub struct UnitOptions { /* private fields */ }Expand description
The reassembler’s per-format settings.
Implementations§
Source§impl UnitOptions
impl UnitOptions
Sourcepub const fn new(
after_continuation: AfterContinuation,
pointer_check: PointerCheck,
duplicates: Duplicates,
max_unit_size: NonZeroUsize,
) -> Self
pub const fn new( after_continuation: AfterContinuation, pointer_check: PointerCheck, duplicates: Duplicates, max_unit_size: NonZeroUsize, ) -> Self
Settings for a format; max_unit_size is the largest unit (header
included) the format can carry, so the buffer is bounded by it.
Examples found in repository?
examples/demux.rs (lines 63-68)
45fn main() {
46 let pkt = TsPacket::parse(&PAT_PACKET).expect("hardcoded packet must parse");
47 println!(
48 "TS packet: pid=0x{:04X} pusi={} has_payload={}",
49 pkt.header.pid.value(),
50 pkt.header.pusi,
51 pkt.header.has_payload()
52 );
53 assert_eq!(pkt.header.pid, well_known::PAT);
54
55 let mut reasm = SectionReassembler::default();
56
57 if let Some(payload) = pkt.payload {
58 reasm.feed(payload, pkt.header.pusi);
59 }
60
61 let mut units = UnitReassembler::new(
62 PatFraming,
63 UnitOptions::new(
64 AfterContinuation::DiscardRest,
65 PointerCheck::Authoritative,
66 Duplicates::Any,
67 std::num::NonZeroUsize::new(1024).unwrap(),
68 ),
69 );
70
71 while let Some(section) = reasm.pop_section() {
72 let mut packets = Vec::new();
73 let count =
74 SectionPacketiser::new(well_known::PAT).packetise_into(&[§ion], &mut packets);
75 println!(
76 "re-packetised {count} PAT packet(s), section: {} bytes, table_id=0x{:02X}",
77 section.len(),
78 section[0]
79 );
80 // The PAT section bytes: table_id=0x00, transport_stream_id at bytes 3-4.
81 if section.len() >= 5 {
82 let ts_id = u16::from_be_bytes([section[3], section[4]]);
83 println!(" transport_stream_id={ts_id}");
84 }
85 if let Some(payload) = pkt.payload {
86 units.feed(payload, pkt.header.pusi, None);
87 if let Some(unit) = units.pop() {
88 println!(" unit reassembled: {} bytes", unit.len());
89 }
90 }
91 }
92}Trait Implementations§
Source§impl Clone for UnitOptions
impl Clone for UnitOptions
impl Copy for UnitOptions
Source§impl Debug for UnitOptions
impl Debug for UnitOptions
impl Eq for UnitOptions
Source§impl PartialEq for UnitOptions
impl PartialEq for UnitOptions
impl StructuralPartialEq for UnitOptions
Auto Trait Implementations§
impl Forget for UnitOptions
impl Freeze for UnitOptions
impl Move for UnitOptions
impl RefUnwindSafe for UnitOptions
impl Send for UnitOptions
impl Sync for UnitOptions
impl Unpin for UnitOptions
impl UnsafeUnpin for UnitOptionswhere
NonZeroUsizeInner: UnsafeUnpin,
impl UnwindSafe for UnitOptions
Blanket Implementations§
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