pub struct Client { /* private fields */ }Expand description
Client to interact with the Last.fm API.
Use Client::builder() to construct a new client.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn get_token(&self) -> Result<String, Error>
pub async fn get_token(&self) -> Result<String, Error>
Get an authentication token.
This token must be approved by the user before exchanging it for a session.
Source§impl Client
impl Client
Sourcepub fn builder(api_key: impl Into<String>) -> ClientBuilder
pub fn builder(api_key: impl Into<String>) -> ClientBuilder
Creates a new builder with the mandatory API key.
§Example
use std::time::Duration;
use soniq::client::Client;
let client = Client::builder("YOUR_API_KEY")
.api_secret("YOUR_API_SECRET")
.timeout(Duration::from_secs(5))
.build()?;Sourcepub async fn unsigned_get<T: DeserializeOwned>(
&self,
method: &str,
params: BTreeMap<String, String>,
) -> Result<T, Error>
pub async fn unsigned_get<T: DeserializeOwned>( &self, method: &str, params: BTreeMap<String, String>, ) -> Result<T, Error>
Performs an unsigned GET request to the Last.fm API.
Sourcepub async fn signed_post<T: DeserializeOwned>(
&self,
method: &str,
params: BTreeMap<String, String>,
) -> Result<T, Error>
pub async fn signed_post<T: DeserializeOwned>( &self, method: &str, params: BTreeMap<String, String>, ) -> Result<T, Error>
Performs a signed POST request without a user session key.
This is for methods that require a signature but don’t operate on a specific user’s account.
Sourcepub async fn signed_post_with_session<T: DeserializeOwned>(
&self,
method: &str,
session_key: Option<&str>,
params: BTreeMap<String, String>,
) -> Result<T, Error>
pub async fn signed_post_with_session<T: DeserializeOwned>( &self, method: &str, session_key: Option<&str>, params: BTreeMap<String, String>, ) -> Result<T, Error>
Performs a signed POST request with an optional user session key.
Pass Some(session_key) to authenticate on behalf of a user.
This requires the client to have been built with an API secret.
Trait Implementations§
Source§impl UserEndpointExt for Client
Implements user() on the client.
impl UserEndpointExt for Client
Implements user() on the client.
fn user(&self) -> UserHandler<'_>
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more