Struct some_random_api::Client

source ·
pub struct Client {
    pub animal: AnimalEndpoint,
    pub animu: AnimuEndpoint,
    pub canvas: CanvasEndpoint,
    pub chatbot: ChatBotEndpoint,
    pub fact: FactEndpoint,
    pub image: ImageEndpoint,
    pub others: OthersEndpoint,
    pub pokemon: PokemonEndpoint,
    pub premium: PremiumEndpoint,
    pub welcome: WelcomeEndpoint,
}

Fields§

§animal: AnimalEndpoint

An endpoint that sends a random image and fact of an animal

Examples

use some_random_api::Client;

Client::new(None::<String>).animal.bird().await?;
§animu: AnimuEndpoint

An endpoint that sends random things related to anime

Examples

use some_random_api::Client;

Client::new(None::<String>).animu.wink().await?;
§canvas: CanvasEndpoint

Canvas-related endpoints

Examples

use some_random_api::Client;
use std::fs::write;

write(
    "jail.png",
    Client::new(None::<String>)
        .canvas
        .overlay
        .jail("url").await?,
)?;
§chatbot: ChatBotEndpoint

Canvas-related endpoints

Examples

use some_random_api::Client;
use std::fs::write;

Client::new(Some("xxxxxxxxxx")).chatbot.chatbot("Hello there").await?;
§fact: FactEndpoint

An endpoint that sends a random fact of an animal

Examples

use some_random_api::Client;

Client::new(None::<String>).fact.bird().await?;
§image: ImageEndpoint

An endpoint that sends a random image of an animal

Examples

use some_random_api::Client;

Client::new(None::<String>).image.bird().await?;
§others: OthersEndpoint

An endpoint that sends other random stuff

Examples

use some_random_api::Client;

Client::new(None::<String>).others.joke().await?;
§pokemon: PokemonEndpoint

An endpoint that sends random Pokemon information

Examples

use some_random_api::Client;

Client::new(None::<String>).pokemon.pokedex("pikachu").await?;
§premium: PremiumEndpoint

Premium-related endpoints

Examples

use some_random_api::Client;
use std::fs::write;

write(
    "jail.png",
    Client::new(None::<String>)
        .premium
        .petpet("url").await?,
)?;
§welcome: WelcomeEndpoint

Welcome message (free)

Examples

use some_random_api::Client;
use std::fs::write;

write(
    "welcome.png",
    Client::new(None::<String>)
        .welcome
        .image(
            ...
        ).await?,
)?;

Implementations§

source§

impl Client

source

pub fn new<T: ToString>(api_key: Option<T>) -> Self

Constructs a new Client

Examples
use some_random_api::Client;

// A client without an API key
Client::new(None::<String>);

// A client with an API key
Client::new(Some("xxxxxxxxxx"));

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.

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