unm_engine/
interface.rs

1use async_trait::async_trait;
2use unm_types::{Context, RetrievedSongInfo, SerializedIdentifier, Song, SongSearchInformation};
3
4#[async_trait]
5/// The engine that can search and track the specified `Song`.
6pub trait Engine {
7    /// Search an audio matched the `info`, and
8    /// return the identifier for retrieving audio URL with `retrieve`.
9    async fn search<'a>(
10        &self,
11        info: &'a Song,
12        ctx: &'a Context,
13    ) -> anyhow::Result<Option<SongSearchInformation>>;
14
15    /// Retrieve the audio URL of the specified `identifier`.
16    async fn retrieve<'a>(
17        &self,
18        identifier: &'a SerializedIdentifier,
19        ctx: &'a Context,
20    ) -> anyhow::Result<RetrievedSongInfo>;
21}