refactor(application): strip comments, DRY ownership check + parse_content_type

This commit is contained in:
2026-07-12 04:10:58 +02:00
parent 98a54245b1
commit 9dcd169689
62 changed files with 56 additions and 203 deletions

View File

@@ -1,10 +1,9 @@
use domain::errors::{DomainError, DomainResult};
use domain::value_objects::ContentType;
use domain::DomainResult;
use super::deps::LibraryQueryDeps;
use super::parse_content_type;
use super::queries::ListGenresQuery;
/// List genres available in the library, optionally filtered.
pub async fn execute(deps: &LibraryQueryDeps, query: ListGenresQuery) -> DomainResult<Vec<String>> {
let content_type = query
.content_type
@@ -17,17 +16,6 @@ pub async fn execute(deps: &LibraryQueryDeps, query: ListGenresQuery) -> DomainR
.await
}
fn parse_content_type(s: &str) -> DomainResult<ContentType> {
match s {
"movie" => Ok(ContentType::Movie),
"episode" => Ok(ContentType::Episode),
"short" => Ok(ContentType::Short),
other => Err(DomainError::ValidationError(format!(
"Unknown content type '{other}'. Use movie, episode, or short."
))),
}
}
#[cfg(test)]
#[path = "tests/list_genres.rs"]
mod tests;