pub struct SpotifyId {
pub id: u128,
pub item_type: SpotifyItemType,
}
Fields§
§id: u128
§item_type: SpotifyItemType
Implementations§
Source§impl SpotifyId
impl SpotifyId
Sourcepub fn is_playable(&self) -> bool
pub fn is_playable(&self) -> bool
Returns whether this SpotifyId
is for a playable audio item, if known.
Sourcepub fn from_base16(src: &str) -> SpotifyIdResult
pub fn from_base16(src: &str) -> SpotifyIdResult
Parses a base16 (hex) encoded Spotify ID into a SpotifyId
.
src
is expected to be 32 bytes long and encoded using valid characters.
Sourcepub fn from_base62(src: &str) -> SpotifyIdResult
pub fn from_base62(src: &str) -> SpotifyIdResult
Parses a base62 encoded Spotify ID into a u128
.
src
is expected to be 22 bytes long and encoded using valid characters.
Sourcepub fn from_raw(src: &[u8]) -> SpotifyIdResult
pub fn from_raw(src: &[u8]) -> SpotifyIdResult
Creates a u128
from a copy of SpotifyId::SIZE
(16) bytes in big-endian order.
The resulting SpotifyId
will default to a SpotifyItemType::Unknown
.
Sourcepub fn from_uri(src: &str) -> SpotifyIdResult
pub fn from_uri(src: &str) -> SpotifyIdResult
Parses a Spotify URI into a SpotifyId
.
uri
is expected to be in the canonical form spotify:{type}:{id}
, where {type}
can be arbitrary while {id}
is a 22-character long, base62 encoded Spotify ID.
Note that this should not be used for playlists, which have the form of
spotify:playlist:{id}
.
Sourcepub fn to_base16(&self) -> Result<String, Error>
pub fn to_base16(&self) -> Result<String, Error>
Returns the SpotifyId
as a base16 (hex) encoded, SpotifyId::SIZE_BASE16
(32)
character long String
.
Sourcepub fn to_base62(&self) -> Result<String, Error>
pub fn to_base62(&self) -> Result<String, Error>
Returns the SpotifyId
as a canonically base62 encoded, SpotifyId::SIZE_BASE62
(22)
character long String
.
Sourcepub fn to_raw(&self) -> [u8; 16]
pub fn to_raw(&self) -> [u8; 16]
Returns a copy of the SpotifyId
as an array of SpotifyId::SIZE
(16) bytes in
big-endian order.
Sourcepub fn to_uri(&self) -> Result<String, Error>
pub fn to_uri(&self) -> Result<String, Error>
Returns the SpotifyId
as a Spotify URI in the canonical form spotify:{type}:{id}
,
where {type}
is an arbitrary string and {id}
is a 22-character long, base62 encoded
Spotify ID.
If the SpotifyId
has an associated type unrecognized by the library, {type}
will
be encoded as unknown
.
Trait Implementations§
Source§impl TryFrom<&ArtistWithRole> for SpotifyId
impl TryFrom<&ArtistWithRole> for SpotifyId
Source§impl TryFrom<&SelectedListContent> for SpotifyId
impl TryFrom<&SelectedListContent> for SpotifyId
Source§impl TryFrom<&TranscodedPicture> for SpotifyId
impl TryFrom<&TranscodedPicture> for SpotifyId
impl Copy for SpotifyId
impl Eq for SpotifyId
impl StructuralPartialEq for SpotifyId
Auto Trait Implementations§
impl Freeze for SpotifyId
impl RefUnwindSafe for SpotifyId
impl Send for SpotifyId
impl Sync for SpotifyId
impl Unpin for SpotifyId
impl UnwindSafe for SpotifyId
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.