Skip to content

Commit

Permalink
clippy: Add missing Error doc and enable lint
Browse files Browse the repository at this point in the history
lint: missing_errors_doc
  • Loading branch information
gwen-lg committed Apr 9, 2024
1 parent c52dc33 commit fdc8d96
Show file tree
Hide file tree
Showing 4 changed files with 14 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 @@ -17,6 +17,7 @@
#![deny(clippy::if_not_else)]
#![deny(clippy::match_same_arms)]
#![deny(clippy::missing_panics_doc)]
#![deny(clippy::missing_errors_doc)]
#![deny(clippy::missing_fields_in_debug)]
#![deny(clippy::must_use_candidate)]
#![deny(clippy::or_fun_call)]
Expand Down
3 changes: 3 additions & 0 deletions src/srt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use std::io;
use crate::time::TimeSpan;

/// Write subtitles in srt format
/// # Errors
///
/// Will return `Err` if write in `writer` return an `Err`.
pub fn write_srt(
data: &[(TimeSpan, String)],
writer: &mut impl io::Write,
Expand Down
3 changes: 3 additions & 0 deletions src/vobsub/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ fn hex_rgb(input: &[u8]) -> IResult<&[u8], Rgb<u8>> {
pub type Palette = [Rgb<u8>; 16];

/// Parse a text as Palette
/// # Errors
///
/// Will return `Err` if the input don't have 16 entries.
pub fn palette(input: &[u8]) -> IResult<&[u8], Palette> {
let res = map_res(separated_list0(tag(b", "), hex_rgb), |vec: Vec<Rgb<u8>>| {
if vec.len() != 16 {
Expand Down
7 changes: 7 additions & 0 deletions src/vobsub/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ fn has_magic(path: &Path, magic: &[u8]) -> Result<bool, SubError> {
}

/// Does the specified path appear to point to an `*.idx` file?
/// # Errors
///
/// Will return `Err` if the file can't be read.
pub fn is_idx_file<P: AsRef<Path>>(path: P) -> Result<bool, SubError> {
has_magic(path.as_ref(), b"# VobSub index file")
}
Expand All @@ -29,6 +32,10 @@ pub fn is_idx_file<P: AsRef<Path>>(path: P) -> Result<bool, SubError> {
///
/// Note that this may (or may not) return false positives for certain
/// MPEG-2 related formats.
///
/// # Errors
///
/// Will return `Err` if the file can't be read.
pub fn is_sub_file<P: AsRef<Path>>(path: P) -> Result<bool, SubError> {
has_magic(path.as_ref(), &[0x00, 0x00, 0x01, 0xba])
}
Expand Down

0 comments on commit fdc8d96

Please sign in to comment.