[−][src]Struct moe::Client
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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,