pub struct Client {
pub credentials: ClientCredentials,
/* private fields */
}
Expand description
A client to the Spotify API.
By default it will use the client credentials
flow
to send requests to the Spotify API. The set_refresh_token
and
redirected
methods tell it to use the authorization code
flow
instead.
Fields§
§credentials: ClientCredentials
Your Spotify client credentials.
Implementations§
Source§impl Client
Endpoint function namespaces.
impl Client
Endpoint function namespaces.
Sourcepub const fn browse(&self) -> Browse<'_>
pub const fn browse(&self) -> Browse<'_>
Endpoint functions related to categories, featured playlists, recommendations, and new releases.
Sourcepub const fn follow(&self) -> Follow<'_>
pub const fn follow(&self) -> Follow<'_>
Endpoint functions related to following and unfollowing artists, users and playlists.
Sourcepub const fn personalization(&self) -> Personalization<'_>
pub const fn personalization(&self) -> Personalization<'_>
Endpoint functions relating to a user’s top artists and tracks.
Sourcepub const fn player(&self) -> Player<'_>
pub const fn player(&self) -> Player<'_>
Endpoint functions related to controlling what is playing on the current user’s Spotify account. (Beta)
Sourcepub const fn tracks(&self) -> Tracks<'_>
pub const fn tracks(&self) -> Tracks<'_>
Endpoint functions related to tracks and audio analysis.
Sourcepub const fn users_profile(&self) -> UsersProfile<'_>
pub const fn users_profile(&self) -> UsersProfile<'_>
Endpoint functions related to users’ profiles.
Source§impl Client
impl Client
Sourcepub fn new(credentials: ClientCredentials) -> Self
pub fn new(credentials: ClientCredentials) -> Self
Create a new client from your Spotify client credentials.
Sourcepub fn with_refresh(
credentials: ClientCredentials,
refresh_token: String,
) -> Self
pub fn with_refresh( credentials: ClientCredentials, refresh_token: String, ) -> Self
Create a new client with your Spotify client credentials and a refresh token.
Sourcepub async fn refresh_token(&self) -> Option<String>
pub async fn refresh_token(&self) -> Option<String>
Get the client’s refresh token.
Sourcepub async fn set_refresh_token(&self, refresh_token: Option<String>)
pub async fn set_refresh_token(&self, refresh_token: Option<String>)
Set the client’s refresh token.
Sourcepub async fn current_access_token(&self) -> (String, Instant)
pub async fn current_access_token(&self) -> (String, Instant)
Get the client’s access token values.
Sourcepub async fn set_current_access_token(&self, token: String, expires: Instant)
pub async fn set_current_access_token(&self, token: String, expires: Instant)
Explicitly override the client’s access token values. Useful if you acquire the access token elsewhere.
Sourcepub async fn redirected(
&self,
url: &str,
state: &str,
) -> Result<(), RedirectedError>
pub async fn redirected( &self, url: &str, state: &str, ) -> Result<(), RedirectedError>
Set the refresh token from the URL the client was redirected to and the state that was used to send them there.
Use the authorization_url()
function to generate the URL to which you can send the
client to to generate the URL here.
§Errors
Fails if the URL is invalid in some way, the state was incorrect for the URL or Spotify fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more