Function ccsds::read_packets

source ·
pub fn read_packets(
    reader: Box<dyn Read + Send>
) -> impl Iterator<Item = IOResult<Packet>> + Send
Expand description

Return an iterator providing Packet data read from a byte synchronized ungrouped packet stream.

For packet streams that may contain packets that utilize packet grouping see read_packet_groups.

§Examples

use ccsds::read_packets;

let dat: &[u8] = &[
    // primary header bytes
    0xd, 0x59, 0xd2, 0xab, 0x0, 07,
    // CDS timecode bytes in secondary header
    0x52, 0xc0, 0x0, 0x0, 0x0, 0xa7, 0x0, 0xdb, 0xff,
    // minimum 1 byte of user data
    0xff
];

let r = std::io::BufReader::new(dat);
read_packets(Box::new(r)).for_each(|zult| {
    let packet = zult.unwrap();
    assert_eq!(packet.header.apid, 1369);
});