[][src]Struct moe::Client

pub struct Client {
    pub base_uri: String,
    pub token: Option<String>,
    // some fields omitted
}

A wrapper around reqwest::Client to talk to trace.moe API.

Fields

base_uri: String

Defaults to "https://trace.moe/api". Primarily useful for testing.

token: Option<String>

Access token that registered developers have.

Methods

impl Client[src]

pub fn new() -> Self[src]

Create a Client with default settings.

pub fn with_token(token: String) -> Self[src]

Create a Client with an API token.

pub fn search(&self, image: Vec<u8>) -> Result<SearchResponse>[src]

Search for image.

Examples

let image = std::fs::read("image.jpg").unwrap();
let response = client.search(image).unwrap();
assert_eq!("Hataraku Saibou", response.docs[0].title_romaji);

Errors

  • HTTP 400 if your search image is empty
  • HTTP 403 if are using an invalid token
  • HTTP 413 if the image is >1MB
  • HTTP 429 if are using requesting too fast
  • HTTP 500 or HTTP 503 if something went wrong in backend

pub fn me(&self) -> Result<Me>[src]

Check the search quota and limit for your account (or IP address).

Examples

let me = client.me().unwrap();
assert_eq!("176.38.191.44", me.email);

Auto Trait Implementations

impl Sync for Client

impl Send for Client

impl Unpin for Client

impl !RefUnwindSafe for Client

impl !UnwindSafe for Client

Blanket Implementations

impl<T> From<T> 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.

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

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

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

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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