pinakes-core: update remaining modules and tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9e0ff5ea33a5cf697473423e88f167ce6a6a6964
This commit is contained in:
parent
c8425a4c34
commit
3d9f8933d2
44 changed files with 1207 additions and 578 deletions
|
|
@ -34,13 +34,25 @@ pub struct ExtractedMetadata {
|
|||
}
|
||||
|
||||
pub trait MetadataExtractor: Send + Sync {
|
||||
/// Extract metadata from a file at the given path.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the file cannot be read or parsed.
|
||||
fn extract(&self, path: &Path) -> Result<ExtractedMetadata>;
|
||||
fn supported_types(&self) -> Vec<MediaType>;
|
||||
}
|
||||
|
||||
/// Extract metadata from a file using the appropriate extractor for the given
|
||||
/// media type.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if no extractor supports the media type, or if extraction
|
||||
/// fails.
|
||||
pub fn extract_metadata(
|
||||
path: &Path,
|
||||
media_type: MediaType,
|
||||
media_type: &MediaType,
|
||||
) -> Result<ExtractedMetadata> {
|
||||
let extractors: Vec<Box<dyn MetadataExtractor>> = vec![
|
||||
Box::new(audio::AudioExtractor),
|
||||
|
|
@ -51,7 +63,7 @@ pub fn extract_metadata(
|
|||
];
|
||||
|
||||
for extractor in &extractors {
|
||||
if extractor.supported_types().contains(&media_type) {
|
||||
if extractor.supported_types().contains(media_type) {
|
||||
return extractor.extract(path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue