use domain::{ContentType, IProviderRegistry, MediaFilter}; use std::sync::Arc; use crate::error::{domain_err, ok_json}; pub async fn list_collections(registry: &Arc) -> String { match registry.list_collections("").await { Ok(cols) => ok_json(&cols), Err(e) => domain_err(e), } } pub async fn list_genres( registry: &Arc, content_type: Option, ) -> String { match registry.list_genres("", content_type.as_ref()).await { Ok(genres) => ok_json(&genres), Err(e) => domain_err(e), } } pub async fn search_media( registry: &Arc, content_type: Option, genres: Vec, search_term: Option, series_names: Vec, collections: Vec, ) -> String { let filter = MediaFilter { content_type, genres, search_term, series_names, collections, ..Default::default() }; match registry.fetch_items("", &filter).await { Ok(items) => ok_json(&items), Err(e) => domain_err(e), } }