WallhavenClient

Struct WallhavenClient 

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

A wallhaven api client.

There are two ways of constructing this object, with or without an api key, see WallhavenClient::new and WallhavenClient::with_key for more details

§Examples

client.wallpaper("someid").await?;
client.search(None).await?;

let req = SearchRequestBuilder::default().build()?;
client.search(Some(req)).await?;

And so on! Check out each methods/models for more informations

Implementations§

Source§

impl WallhavenClient

Source

pub fn with_key(api_key: impl AsRef<str>) -> Result<Self, Error>

Constructs WallhavenClient with an api key Check out WallhavenClient::new to construct an instance without an api key. The api key will be passed to the X-API-Key headers.

§Errors
Source

pub fn new() -> Result<Self, Error>

Constructs WallhavenClient without an api key. Check out WallhavenClient::with_key to construct an instance with an api key.

§Errors
  • Error::BuildingClient when something went wrong with the Client builder, this shouldn’t happen and you probably should file an issue
Source

pub async fn wallpaper( &self, id: impl AsRef<str>, ) -> Result<WallpaperDetails, Error>

Fetches a wallpaper by id

§Errors
Source

pub async fn search( &self, params: Option<SearchRequest>, ) -> Result<SearchResult, Error>

Searches for wallpapers matching the request

§Errors
Source

pub async fn collections( &self, username: impl Into<Option<String>>, ) -> Result<Vec<UserCollection>, Error>

Fetches all the UserCollection of a certain user

Defaults to the current if no username is provided and an api key is used

§Errors
Source

pub async fn collection_items( &self, username: impl AsRef<str>, id: u64, params: Option<CollectionItemsRequest>, ) -> Result<SearchResult, Error>

Gets the collection’s wallpapers.

§Errors
Source

pub async fn tag(&self, id: u64) -> Result<Tag, Error>

Fetches a Tag by its id

§Errors
Source

pub async fn user_settings(&self) -> Result<UserSettings, Error>

Fetches the UserSettings of the current user. Only works if the api key was provided.

§Errors
Source

pub async fn download_wallpaper( &self, wallpaper: &impl HasPath, ) -> Result<impl Stream<Item = Result<Bytes>>, Error>

Downloads a any wallpaper type (e.g. WallhavenDetails or WallhavenSummary)

§Errors
  • Error::SendingRequest an error while sending the request, you can get more details with the underlying error
  • Error::UnknownRequestError - an unknown error when sending/receiving the request, you can match further the underlying error
Source

pub async fn download_thumbnail( &self, thumbnail: &Thumbnails, resolution: ThumbnailResolution, ) -> Result<impl Stream<Item = Result<Bytes>>, Error>

Downloads a Thumbnails

§Errors
  • Error::SendingRequest an error while sending the request, you can get more details with the underlying error
  • Error::UnknownRequestError - an unknown error when sending/receiving the request, you can match further the underlying error

Trait Implementations§

Source§

impl Clone for WallhavenClient

Source§

fn clone(&self) -> WallhavenClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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