mod flac; use std::{collections::HashMap, sync::Arc}; pub use flac::*; mod id3; pub use id3::*; mod fs; pub use fs::*; mod epub; pub use epub::*; mod exif; pub use exif::*; mod pdf; pub use pdf::*; mod toml; use pile_config::Label; pub use toml::*; mod sidecar; pub use sidecar::*; use crate::{ extract::{misc::MapExtractor, traits::ObjectExtractor}, value::{Item, PileValue}, }; pub struct ItemExtractor { inner: MapExtractor, } impl ItemExtractor { #[expect(clippy::unwrap_used)] pub fn new(item: &Item) -> Self { let inner = MapExtractor { inner: HashMap::from([ ( Label::new("flac").unwrap(), PileValue::ObjectExtractor(Arc::new(FlacExtractor::new(item))), ), ( Label::new("id3").unwrap(), PileValue::ObjectExtractor(Arc::new(Id3Extractor::new(item))), ), ( Label::new("fs").unwrap(), PileValue::ObjectExtractor(Arc::new(FsExtractor::new(item))), ), ( Label::new("epub").unwrap(), PileValue::ObjectExtractor(Arc::new(EpubExtractor::new(item))), ), ( Label::new("exif").unwrap(), PileValue::ObjectExtractor(Arc::new(ExifExtractor::new(item))), ), ( Label::new("pdf").unwrap(), PileValue::ObjectExtractor(Arc::new(PdfExtractor::new(item))), ), ( Label::new("toml").unwrap(), PileValue::ObjectExtractor(Arc::new(TomlExtractor::new(item))), ), ( Label::new("sidecar").unwrap(), PileValue::ObjectExtractor(Arc::new(SidecarExtractor::new(item))), ), ]), }; Self { inner } } } #[async_trait::async_trait] impl ObjectExtractor for ItemExtractor { async fn field(&self, name: &pile_config::Label) -> Result, std::io::Error> { self.inner.field(name).await } #[expect(clippy::unwrap_used)] async fn fields(&self) -> Result, std::io::Error> { return Ok(vec![ Label::new("flac").unwrap(), Label::new("id3").unwrap(), Label::new("fs").unwrap(), Label::new("epub").unwrap(), Label::new("exif").unwrap(), Label::new("pdf").unwrap(), Label::new("sidecar").unwrap(), ]); } }