Struct SpotifyCallback

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

The Spotify Callback URL

This struct follows the parameters given at this link.

The main use of this object is to convert the callback URL into an object that can be used to generate a token. If needed you can also create this callback object using the new function in the struct.

§Example

// Create a new spotify callback object using the callback url given by the authorization process.
// This object can then be converted into the token needed for the application.
let callback = SpotifyCallback::from_str("https://example.com/callback?code=NApCCgBkWtQ&state=test").unwrap();

Implementations§

Source§

impl SpotifyCallback

Conversion and helper functions for SpotifyCallback.

Source

pub fn new(code: Option<String>, error: Option<String>, state: String) -> Self

Create a new Spotify Callback object with given values.

§Example
// Create a new spotify callback object using the new function.
// This object can then be converted into the token needed for the application.
let callback = SpotifyCallback::new(Some("NApCCgBkWtQ".to_string()), None, String::from("test"));
Source

pub async fn convert_into_token( self, client_id: String, client_secret: String, redirect_uri: Url, ) -> Result<SpotifyToken, SpotifyError>

Converts the Spotify Callback object into a Spotify Token object.

§Example
// Create a new Spotify auth object.
let auth = SpotifyAuth::new("00000000000".into(), "secret".into(), "code".into(), "http://localhost:8000/callback".into(), vec![SpotifyScope::Streaming], false);

// Create a new spotify callback object using the callback url given by the authorization process and convert it into a token.
let token = SpotifyCallback::from_str("https://example.com/callback?code=NApCCgBkWtQ&state=test").unwrap()
    .convert_into_token(auth.client_id, auth.client_secret, auth.redirect_uri).await.unwrap();

Trait Implementations§

Source§

impl Debug for SpotifyCallback

Source§

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

Formats the value using the given formatter. Read more
Source§

impl FromStr for SpotifyCallback

Implementation of FromStr for Spotify Callback URLs.

§Example

// Create a new spotify callback object using the callback url given by the authorization process.
// This object can then be converted into the token needed for the application.
let callback = SpotifyCallback::from_str("https://example.com/callback?code=NApCCgBkWtQ&state=test").unwrap();
Source§

type Err = SpotifyError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for SpotifyCallback

Source§

fn eq(&self, other: &SpotifyCallback) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SpotifyCallback

Auto Trait Implementations§

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, 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, 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> ErasedDestructor for T
where T: 'static,