[][src]Struct ksoft::music::Music

pub struct Music {
    pub http: Arc<HttpClient>,
}

Fields

http: Arc<HttpClient>

Implementations

impl Music[src]

pub fn new(http_client: Arc<HttpClient>) -> Self[src]

pub async fn advanced_lyrics<'_>(
    &'_ self,
    query: impl ToString,
    text_only: bool,
    limit: u32
) -> Result<Lyrics>
[src]

Get lyrics of a song specifying custom parameters

Example

This example is not tested
if let Ok(res) = client.music.advanced_lyrics("despacito", false, 10).await {
    match res {
        Ok(lyrics) => {
            //do something with lyrics
        },
        Err(why) => {
            //do something with the <MusicError> struct
        }
    }
}

pub async fn lyrics<'_>(&'_ self, query: impl ToString) -> Result<Lyrics>[src]

Get lyrics of a song

Example

This example is not tested
if let Ok(res) = client.music.lyrics("despacito").await {
    match res {
        Ok(lyrics) => {
            //do something with lyrics
        },
        Err(why) => {
            //do something with the <MusicError> struct
        }
    }
}

pub async fn advanced_recommendations<'_>(
    &'_ self,
    tracks: ProviderType,
    youtube_token: Option<String>,
    limit: Option<u32>,
    recommend_type: Option<String>
) -> HttpResult<MusicRecommendationsResponse, MusicError>
[src]

Get recommendations of songs with given query specifying custom parameters

You need a premium plan to use this endpoint

Example

This example is not tested
if let Ok(res) = client.music.advanced_recommendations(
        ProviderType::YoutubeTitles(vec![String::from("despacito")]), None, None, None).await {
    match res {
        Ok(recommendations) => {
            //do something with recommendations
        },
        Err(why) => {
            //do something with the <MusicError> struct
        }
    }

pub async fn recommendations<'_>(
    &'_ self,
    tracks: ProviderType
) -> HttpResult<MusicRecommendationsResponse, MusicError>
[src]

Get recommendations of songs with given query

You need a premium plan to use this endpoint

Example

This example is not tested
if let Ok(res) = client.music.recommendations(
        ProviderType::YoutubeTitles(vec![String::from("despacito")])).await {
    match res {
        Ok(recommendations) => {
            //do something with recommendations
        },
        Err(why) => {
            //do something with the <MusicError> struct
        }
    }

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.