Skip to content

Commit

Permalink
deny missing docs
Browse files Browse the repository at this point in the history
Implement missing documentations.
  • Loading branch information
ystreet committed Jan 16, 2025
1 parent 514062d commit f8b8eac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// copied, modified, or distributed except according to those terms.

#![deny(missing_debug_implementations)]
#![deny(missing_docs)]

//! # cdp-types
//!
Expand Down
9 changes: 9 additions & 0 deletions src/svc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use crate::ParserError;
use crate::WriterError;

/// A Closed Caption Service Information block as stored in CDP (SMPTE 334-2).
#[derive(Debug, PartialEq, Eq, Default, Clone)]
pub struct ServiceInfo {
start: bool,
Expand Down Expand Up @@ -261,12 +262,15 @@ impl ServiceEntry {
&self.service
}

/// Write this entry into a byte sequence.
pub fn write<W: std::io::Write>(&mut self, w: &mut W) -> Result<(), std::io::Error> {
let mut data = [0; 6];
self.write_into_unchecked(&mut data);
w.write_all(&data)
}

/// Write this entry into a preallocated sequence of bytes. The destination `buf` must have
/// a length of at least 6 bytes.
pub fn write_into_unchecked(&self, data: &mut [u8]) {
data[0] = self.language[0];
data[1] = self.language[1];
Expand Down Expand Up @@ -305,6 +309,7 @@ pub enum FieldOrService {
Service(DigitalServiceEntry),
}

/// A service entry for digital closed captions, i.e. CEA-708 captions.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct DigitalServiceEntry {
service: u8,
Expand All @@ -313,6 +318,7 @@ pub struct DigitalServiceEntry {
}

impl DigitalServiceEntry {
/// Construct a new [`DigitalServiceEntry`]
pub fn new(service: u8, easy_reader: bool, wide_aspect_ratio: bool) -> Self {
Self {
service,
Expand All @@ -321,14 +327,17 @@ impl DigitalServiceEntry {
}
}

/// The service number of this entry.
pub fn service_no(&self) -> u8 {
self.service
}

/// Whether this service is an easy reader type.
pub fn easy_reader(&self) -> bool {
self.easy_reader
}

/// Whether a wide aspect ratio (16:9) is being used here or not (4:3).
pub fn wide_aspect_ratio(&self) -> bool {
self.wide_aspect_ratio
}
Expand Down
3 changes: 3 additions & 0 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl Default for CDPWriter {
}

impl CDPWriter {
/// Construct a new [`CDPWriter`].
pub fn new() -> Self {
Self::default()
}
Expand All @@ -44,10 +45,12 @@ impl CDPWriter {
self.cc_data.push_cea608(cea608)
}

/// Set the optional time code to use for the next CDP packet that is generated.
pub fn set_time_code(&mut self, time_code: Option<TimeCode>) {
self.time_code = time_code;
}

/// Set the optional [`ServiceInfo`] for the next CDP packet that is generated.
pub fn set_service_info(&mut self, service_info: Option<ServiceInfo>) {
self.service_info = service_info;
}
Expand Down

0 comments on commit f8b8eac

Please sign in to comment.