Struct Client

Source
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.

Source

pub const fn albums(&self) -> Albums<'_>

Album-related endpoints.

Source

pub const fn artists(&self) -> Artists<'_>

Artist-related endpoints.

Source

pub const fn browse(&self) -> Browse<'_>

Endpoint functions related to categories, featured playlists, recommendations, and new releases.

Source

pub const fn episodes(&self) -> Episodes<'_>

Episode-related endpoints.

Source

pub const fn follow(&self) -> Follow<'_>

Endpoint functions related to following and unfollowing artists, users and playlists.

Source

pub const fn library(&self) -> Library<'_>

Endpoints relating to saving albums and tracks.

Source

pub const fn personalization(&self) -> Personalization<'_>

Endpoint functions relating to a user’s top artists and tracks.

Source

pub const fn player(&self) -> Player<'_>

Endpoint functions related to controlling what is playing on the current user’s Spotify account. (Beta)

Source

pub const fn playlists(&self) -> Playlists<'_>

Endpoint functions related to playlists.

Source

pub const fn search(&self) -> Search<'_>

Endpoint functions related to searches.

Source

pub const fn shows(&self) -> Shows<'_>

Endpoint functions related to shows.

Source

pub const fn tracks(&self) -> Tracks<'_>

Endpoint functions related to tracks and audio analysis.

Source

pub const fn users_profile(&self) -> UsersProfile<'_>

Endpoint functions related to users’ profiles.

Source§

impl Client

Source

pub fn new(credentials: ClientCredentials) -> Self

Create a new client from your Spotify client credentials.

Source

pub fn with_refresh( credentials: ClientCredentials, refresh_token: String, ) -> Self

Create a new client with your Spotify client credentials and a refresh token.

Source

pub async fn refresh_token(&self) -> Option<String>

Get the client’s refresh token.

Source

pub async fn set_refresh_token(&self, refresh_token: Option<String>)

Set the client’s refresh token.

Source

pub async fn current_access_token(&self) -> (String, Instant)

Get the client’s access token values.

Source

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.

Source

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§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,