pub struct Token {
    pub access_token: String,
    pub expires_in: Duration,
    pub expires_at: Option<DateTime<Utc>>,
    pub refresh_token: Option<String>,
    pub scopes: HashSet<String, RandomState>,
}
Expand description

Spotify access token information

Reference

Fields

access_token: String

An access token that can be provided in subsequent calls

expires_in: Duration

The time period for which the access token is valid.

expires_at: Option<DateTime<Utc>>

The valid time for which the access token is available represented in ISO 8601 combined date and time.

refresh_token: Option<String>

A token that can be sent to the Spotify Accounts service in place of an authorization code

scopes: HashSet<String, RandomState>

A list of scopes which have been granted for this access_token

You may use the scopes! macro in rspotify-macros to build it at compile time easily.

Implementations

Tries to initialize the token from a cache file.

Saves the token information into its cache file.

Check if the token is expired. It includes a margin of 10 seconds (which is how much a request would take in the worst case scenario).

Generates an HTTP token authorization header with proper formatting

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.