use domain::{RepositoryError, Song, SongRepositoryPort, SongSearchPort, SongSummary, StoredSong}; use uuid::Uuid; pub struct SongService { repo: Box, } impl SongService { pub fn new(repo: Box) -> Self { Self { repo } } pub async fn save(&self, song: &Song) -> Result { self.repo.save(song).await } pub async fn list(&self) -> Result, RepositoryError> { self.repo.list().await } pub async fn get(&self, id: Uuid) -> Result, RepositoryError> { self.repo.get(id).await } pub async fn delete(&self, id: Uuid) -> Result<(), RepositoryError> { self.repo.delete(id).await } pub async fn update_meta( &self, id: Uuid, title: Option<&str>, artist: Option<&str>, original_key: Option<&str>, ) -> Result { self.repo.update_meta(id, title, artist, original_key).await } } pub struct SongSearchService { search: Box, } impl SongSearchService { pub fn new(search: Box) -> Self { Self { search } } pub async fn search(&self, query: &str) -> Result, domain::RepositoryError> { self.search.search(query).await } }