Skip to content

Commit

Permalink
docs: add documentation comments for Format struct and its methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tamada committed Feb 4, 2025
1 parent 780765d commit d69c5c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl Manager {
}
}

/// Represents the archive format.
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Format {
pub name: String,
Expand All @@ -108,13 +109,15 @@ impl From<Format> for String {
}

impl Format {
/// Create an instanceof Format with the name and its extensions.
pub fn new<T: Into<String>>(name: T, exts: Vec<T>) -> Self {
Self {
name: name.into(),
exts: exts.into_iter().map(|e| e.into().to_lowercase()).collect(),
}
}

/// Returns `true` if the given file name has the extension of this format.
pub fn is_match<P: AsRef<Path>>(&self, p: P) -> bool {
let p = p.as_ref();
let name = p.to_str().unwrap().to_lowercase();
Expand Down

0 comments on commit d69c5c4

Please sign in to comment.