//! Collections API. use alloc::sync::Arc; use std::sync::RwLock; use crate::api::exec_request; use crate::model::Collection; use crate::model::id::CollectionId; use crate::{Cache, CachePolicy, Config}; use super::{Error, make_request}; /// TMDB Collections API client. #[derive(Debug)] pub struct Client { /// The client configuration. config: Arc, /// The request cache. cache: Arc, /// The cache policy to use for requests. policy: Arc>, } impl Client { /// Create a new client with the given configuration. #[inline] pub fn new( config: Arc, cache: Arc, policy: Arc>, ) -> Self { Self { config, cache, policy, } } /// Fetch the details of the collection refered to by ID. /// /// # Errors /// See [Error] for failure modes. #[inline] #[expect(clippy::impl_trait_in_params, reason = "turbofish is not expected")] pub async fn get_details( &self, id: impl Into, language: Option<&str>, ) -> Result { let request = make_request( &self.config, &format!("/3/collection/{}", id.into().into_raw()), language, )?; exec_request(&self.config, &*self.cache, &self.policy, request).await } }