Struct cea708_types::DTVCCPacket
source · pub struct DTVCCPacket { /* private fields */ }
Expand description
A packet in the cc_data
bitstream
Implementations§
source§impl DTVCCPacket
impl DTVCCPacket
sourcepub fn sequence_no(&self) -> u8
pub fn sequence_no(&self) -> u8
The sequence number of the DTVCCPacket
§Examples
let packet = DTVCCPacket::new(2);
assert_eq!(2, packet.sequence_no());
sourcepub fn free_space(&self) -> usize
pub fn free_space(&self) -> usize
The amount of free space (in bytes) that can by placed inside this DTVCCPacket
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The number of bytes this DTVCCPacket will use when written to a byte stream.
§Examples
let mut packet = DTVCCPacket::new(2);
assert_eq!(0, packet.len());
let mut service = Service::new(1);
service.push_code(&Code::LatinCapitalA).unwrap();
packet.push_service(service);
assert_eq!(3, packet.len());
sourcepub fn push_service(&mut self, service: Service) -> Result<(), WriterError>
pub fn push_service(&mut self, service: Service) -> Result<(), WriterError>
Push a completed service block into this DTVCCPacket
§Examples
let mut packet = DTVCCPacket::new(2);
assert_eq!(0, packet.len());
let mut service = Service::new(1);
service.push_code(&Code::LatinCapitalA).unwrap();
packet.push_service(service);
assert_eq!(3, packet.len());
sourcepub fn parse(data: &[u8]) -> Result<Self, ParserError>
pub fn parse(data: &[u8]) -> Result<Self, ParserError>
Parse bytes into a DTVCCPacket
Will return ParserError::LengthMismatch if the data is shorter than the length advertised in the DTVCCPacket header.
Will return errors from Service::parse if parsing the contained Services fails.
§Examples
let data = [0x02, 0x21, 0x41, 0x00];
let packet = DTVCCPacket::parse(&data).unwrap();
assert_eq!(3, packet.len());
assert_eq!(0, packet.sequence_no());
sourcepub fn services(&self) -> &[Service]
pub fn services(&self) -> &[Service]
Returns a copy of the Services for this DTVCCPacket
sourcepub fn write<W: Write>(&self, w: &mut W) -> Result<(), Error>
pub fn write<W: Write>(&self, w: &mut W) -> Result<(), Error>
Write the DTVCCPacket to a byte stream
§Examples
let mut packet = DTVCCPacket::new(2);
let mut service = Service::new(1);
service.push_code(&Code::LatinCapitalA).unwrap();
packet.push_service(service);
let mut written = vec![];
packet.write(&mut written);
let expected = [0x82, 0x21, 0x41, 0x00];
assert_eq!(written, expected);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DTVCCPacket
impl RefUnwindSafe for DTVCCPacket
impl Send for DTVCCPacket
impl Sync for DTVCCPacket
impl Unpin for DTVCCPacket
impl UnwindSafe for DTVCCPacket
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