Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

The application’s Spotify client

Implementations§

Source§

impl Client

Source

pub fn new(session: Session, auth_config: AuthConfig, client_id: String) -> Self

Construct a new client

Source

pub fn username(&self) -> UserId<'_>

Get the UserName of Spotify

Source

pub async fn check_valid_session(&self) -> Result<()>

Check if the current session is valid and if invalid, create a new session

Source

pub async fn browse_categories(&self) -> Result<Vec<Category>>

Get Spotify’s available browse categories

Source

pub async fn browse_category_playlists( &self, category_id: &str, ) -> Result<Vec<Playlist>>

Get Spotify’s available browse playlists of a given category

Source

pub async fn current_user_saved_tracks(&self) -> Result<Vec<Track>>

Get the saved (liked) tracks of the current user

Source

pub async fn current_user_recently_played_tracks(&self) -> Result<Vec<Track>>

Get the recently played tracks of the current user

Source

pub async fn current_user_top_tracks(&self) -> Result<Vec<Track>>

Get the top tracks of the current user

Source

pub async fn current_user_playlists(&self) -> Result<Vec<Playlist>>

Get all playlists of the current user

Source

pub async fn current_user_followed_artists(&self) -> Result<Vec<Artist>>

Get all followed artists of the current user

Source

pub async fn current_user_saved_albums(&self) -> Result<Vec<Album>>

Get all saved albums of the current user

Source

pub async fn artist_albums(&self, artist_id: ArtistId<'_>) -> Result<Vec<Album>>

Get all albums of an artist

Source

pub async fn radio_tracks(&self, seed_uri: String) -> Result<Vec<Track>>

Get recommendation (radio) tracks based on a seed

Source

pub async fn search(&self, query: &str) -> Result<SearchResults>

Search for items (tracks, artists, albums, playlists) matching a given query

Source

pub async fn search_specific_type( &self, query: &str, _type: SearchType, ) -> Result<SearchResult>

Search for items of a specific type matching a given query

Source

pub async fn add_track_to_playlist( &self, playlist_id: PlaylistId<'_>, track_id: TrackId<'_>, ) -> Result<()>

Add a track to a playlist

Source

pub async fn add_tracks_to_playlist(&self) -> Result<()>

Source

pub async fn delete_track_from_playlist( &self, playlist_id: PlaylistId<'_>, track_id: TrackId<'_>, ) -> Result<()>

Remove a track from a playlist

Source

pub async fn playlist_context( &self, playlist_id: PlaylistId<'_>, ) -> Result<Context>

Get a playlist context data

Source

pub async fn album_context(&self, album_id: AlbumId<'_>) -> Result<Context>

Get an album context data

Source

pub async fn artist_context(&self, artist_id: ArtistId<'_>) -> Result<Context>

Get an artist context data

Trait Implementations§

Source§

impl Deref for Client

Source§

type Target = Spotify

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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,