Struct cea708_types::Service
source · pub struct Service { /* private fields */ }
Expand description
A Service in a DTVCCPacket
As specified in CEA-708, there can be a maximum of 63 services. Service 1 is the primary caption service and Service 2 is the secondary caption service. All other services are undefined.
Implementations§
source§impl Service
impl Service
sourcepub fn free_space(&self) -> usize
pub fn free_space(&self) -> usize
sourcepub fn push_code(&mut self, code: &Code) -> Result<(), WriterError>
pub fn push_code(&mut self, code: &Code) -> Result<(), WriterError>
Push a tables::Code to the end of this Service
§Errors
- WriterError::ReadOnly if Service is number 0 (called the NULL Service)
- WriterError::WouldOverflow if adding the tables::Code would cause to Service to overflow
§Examples
let mut service = Service::new(1);
service.push_code(&Code::LatinCapitalA).unwrap();
sourcepub fn parse(data: &[u8]) -> Result<Self, ParserError>
pub fn parse(data: &[u8]) -> Result<Self, ParserError>
Parse a Service from a set of bytes
§Errors
- ParserError::LengthMismatch if the length of the data is less than the size advertised in the header
§Examples
let bytes = [0x21, 0x41];
let service = Service::parse(&bytes).unwrap();
assert_eq!(service.number(), 1);
assert_eq!(service.codes()[0], Code::LatinCapitalA);
sourcepub fn codes(&self) -> &[Code]
pub fn codes(&self) -> &[Code]
The ordered list of tables::Codes present in this Service block
§Examples
let mut service = Service::new(1);
service.push_code(&Code::LatinCapitalA).unwrap();
let codes = service.codes();
assert_eq!(codes, [Code::LatinCapitalA]);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Service
impl RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnwindSafe for Service
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