Struct megamind::Client

source ·
pub struct Client { /* private fields */ }
Expand description

An HTTP client for interacting with the Genius API.

Essentially just a thin wrapper around reqwest::Client, meaning that if you want more control/need to access a missing endpoint then you can just use the data models with Reqwest directly.

This also means that you can clone this client freely and should not use std::sync::Arc or std::rc::Rc, much like reqwest::Client.

Implementations§

source§

impl Client

source

pub async fn account(&self) -> Result<Response<AccountResponse>, ClientError>

Get the account info for the currently authed user.

Requires scope: me.

Returns

The current user.

source

pub async fn annotation( &self, id: u32 ) -> Result<Response<AnnotationResponse>, ClientError>

Get an annotation.

Args
  • id - A Genius ID.
Returns

The annotation associated with the ID.

source

pub async fn artist( &self, id: u32 ) -> Result<Response<ArtistResponse>, ClientError>

Get an artist.

Args
  • id - A Genius ID.
Returns

The artist associated with the ID.

source

pub async fn referents( &self, created_by: Option<u32>, associated: Option<ReferentAssociation>, per_page: Option<u8>, page: Option<u8> ) -> Result<Response<ReferentsResponse>, ClientError>

Get referents.

Args
  • created_by - A Genius ID.
  • associated - The associated web page or song.
  • per_page - A per-page limit.
  • page - A page offset, starting at 1.
Returns

The referents that are associated with the web page or song and/or are created by a user with the given Genius ID. Results follow the per_page and page rules, and there are some failure cases that the argument types can’t prevent so please visit the Genius documentation for more information.

source

pub async fn search<S: AsRef<str>>( &self, query: S ) -> Result<Response<SearchResponse>, ClientError>

Get search results.

Args
  • query - A search term to match against.
Returns

Search results associated with the query.

source

pub async fn song(&self, id: u32) -> Result<Response<SongResponse>, ClientError>

Get a song.

Args
  • id - A Genius ID.
Returns

The song associated with the ID.

source

pub async fn user(&self, id: u32) -> Result<Response<UserResponse>, ClientError>

Get a user.

Args
  • id - A Genius ID.
Returns

The user associated with the ID.

source

pub async fn web_pages( &self, raw_annotatable_url: Option<&str>, canonical_url: Option<&str>, og_url: Option<&str> ) -> Result<Response<WebPageResponse>, ClientError>

Get a web page.

Args
  • raw_annotatable_url - The URL as it would appear in a browser.
  • canonical_url - The URL as specified by an appropriate tag in a page’s .
  • og_url - The URL as specified by an og:url tag in a page’s .
Returns

The web page associated with the above arguments.

Trait Implementations§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Client

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more