//! Deezer client. use std::error::Error; use serde::Deserialize; /// A user. #[derive(Debug, Deserialize)] pub struct User { /// The user ID. pub id: u32, /// The user name. pub name: String, } /// Deezer client. #[derive(Default)] pub struct DeezerClient { client: reqwest::Client, api_url: &'static str, } impl DeezerClient { /// Creates a new Deezer client. #[must_use] pub fn new() -> Self { Self { client: reqwest::Client::new(), api_url: "https://api.deezer.com", } } /// Returns the authenticated user. pub async fn get_me(&self) -> Result> { let user = self .client .get(format!("{}/user/me", self.api_url)) .send() .await? .json::() .await?; Ok(user) } }