Skip to content

Commit

Permalink
provider: update metadata provider api to include a upcasting method
Browse files Browse the repository at this point in the history
  • Loading branch information
vgarleanu committed Jun 26, 2022
1 parent b362a9f commit 54b3a18
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dim/src/external/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Module contains a common interface for extracting and obtaining filename metadata.
pub mod filename;

use async_trait::async_trait;

use std::sync::Arc;
Expand Down Expand Up @@ -87,7 +90,7 @@ pub struct ExternalActor {
/// Trait that must be implemented by external metadata agents which allows the scanners to query
/// for data.
#[async_trait]
pub trait ExternalQuery {
pub trait ExternalQuery: Send + Sync {
/// Search by title and year. This must return a Vec of `ExternalMedia` sorted by the search
/// score.
async fn search(&self, title: &str, year: Option<i32>) -> Result<Vec<ExternalMedia>>;
Expand All @@ -96,6 +99,12 @@ pub trait ExternalQuery {
async fn search_by_id(&self, external_id: &str) -> Result<ExternalMedia>;
/// Get all actors for an external id. Actors must be ordered in order of importance.
async fn actors(&self, external_id: &str) -> Result<Vec<ExternalActor>>;

/// Upcast `self` into `ExternalQueryShow`. It is important that providers that can query for
/// tv shows, implements this to return `Some(self)`.
fn as_query_show<'a>(&'a self) -> Option<&dyn ExternalQueryShow> {
None
}
}

/// Trait must be implemented by all external metadata agents which support querying for tv shows.
Expand Down

0 comments on commit 54b3a18

Please sign in to comment.