tmdb_api/
prelude.rs

1use std::borrow::Cow;
2
3use crate::client::Executor;
4
5pub trait Command: Sync {
6    type Output: serde::de::DeserializeOwned;
7
8    fn path(&self) -> Cow<'static, str>;
9    fn params(&self) -> Vec<(&'static str, Cow<'_, str>)>;
10
11    fn execute<E: Executor + Send + Sync>(
12        &self,
13        client: &crate::Client<E>,
14    ) -> impl Future<Output = Result<Self::Output, crate::error::Error>> + Send {
15        async move { client.execute(self.path().as_ref(), self.params()).await }
16    }
17}