pub fn iter_packets(buf: &[u8]) -> impl Iterator<Item = TsPacket<'_>>Expand description
Iterate over all valid TS packets in a byte buffer.
Slices buf into 188-byte chunks (using slice::chunks_exact) and yields
each chunk for which TsPacket::parse succeeds. Chunks with a bad sync byte
(!= 0x47) or insufficient length are silently skipped — use
crate::resync::TsResync for byte-stream resynchronisation before calling
this when byte alignment is not guaranteed.
§Example
for pkt in iter_packets(data) {
println!("PID: 0x{:04X}", pkt.header.pid);
}