[][src]Struct rustnao::Handler

pub struct Handler { /* fields omitted */ }

A handler struct to make SauceNAO API calls.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));

Methods

impl Handler[src]

pub const H_MAGAZINES: u32[src]

Associated index for H-Magazines.

pub const H_GAME_CG: u32[src]

Associated index for H-Game CG.

pub const DOUJINSHI_DB: u32[src]

Associated index for DoujinshiDB.

pub const PIXIV: u32[src]

Associated index for Pixiv.

pub const NICO_NICO_SEIGA: u32[src]

Associated index for Nico Nico Seiga.

pub const DANBOORU: u32[src]

Associated index for Danbooru.

pub const DRAWR: u32[src]

Associated index for drawr Images.

pub const NIJIE: u32[src]

Associated index for Nijie Images.

pub const YANDE_RE: u32[src]

Associated index for Yand.ere.

pub const SHUTTERSTOCK: u32[src]

Associated index for Shutterstock.

pub const FAKKU: u32[src]

Associated index for Fakku.

pub const H_MISC: u32[src]

Associated index for H-Misc.

pub const TWO_D_MARKET: u32[src]

Associated index for 2D-Market.

pub const MEDIBANG: u32[src]

Associated index for MediBang.

pub const ANIME: u32[src]

Associated index for Anime.

pub const H_ANIME: u32[src]

Associated index for H-Anime.

pub const MOVIES: u32[src]

Associated index for Movies.

pub const SHOWS: u32[src]

Associated index for Shows.

pub const GELBOORU: u32[src]

Associated index for Gelbooru.

pub const KONACHAN: u32[src]

Associated index for Konachan.

pub const SANKAKU_CHANNEL: u32[src]

Associated index for Sankaku Channel.

pub const ANIME_PICTURES_NET: u32[src]

Associated index for Anime-Pictures.net.

pub const E621_NET: u32[src]

Associated index for e621.net.

pub const IDOL_COMPLEX: u32[src]

Associated index for Idol Complex.

pub const BCY_NET_ILLUST: u32[src]

Associated index for bcy.net Illust.

pub const BCY_NET_COSPLAY: u32[src]

Associated index for bcy.net Cosplay.

pub const PORTALGRAPHICS_NET: u32[src]

Associated index for PortalGraphics.net.

pub const DEVIANTART: u32[src]

Associated index for deviantArt.

pub const PAWOO_NET: u32[src]

Associated index for Pawoo.net.

pub const MADOKAMI: u32[src]

Associated index for Madokami.

pub const MANGADEX: u32[src]

Associated index for Mangadex.

pub fn new(
    api_key: &str,
    testmode: Option<i32>,
    db_mask: Option<Vec<u32>>,
    db_mask_i: Option<Vec<u32>>,
    db: Option<u32>,
    num_results: Option<i32>
) -> Handler
[src]

Creates a new Handler object. By default, the short limit is set to 30 seconds, and the long limit is set to 24 hours.

Arguments

  • api_key - A string slice holding your api key.
  • testmode - An Option for a i32, either 0 or 1. Causes each index which has to output at most 1 for testing. If this is None, this is by default 0.
  • db_mask - A Option for a vector of i32 values representing a mask for which database indices you wish to have enabled.
  • db_mask_i - A Option for a vector of i32 values representing a mask for which database indices you wish to have disabled.
  • db - An Option for a u32 value to search for a specific index. Set to 999 for all. If this and db_mask are both empty/None, by default it searches all before dbmaski is applied.
  • num_results - An Option for a i32 representing the number of results you wish returned. If this is None, this is by default 999.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));

pub fn set_min_similarity<T: Into<f64>>(&self, similarity: T)[src]

Sets the minimum similarity threshold for get_sauce.

Arguments

  • similarity - Represents the minimum similarity threshold (in percent) you wish to set. It can be any value that can convert to a f64. This includes f32s, i16s, i32s, and i8s.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
handle.set_min_similarity(50);

pub fn get_short_limit(&self) -> u32[src]

Gets the current short limit as an i32. By default this is 12.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
println!("{}", handle.get_short_limit());

pub fn get_long_limit(&self) -> u32[src]

Gets the current long limit as an i32. By default this is 200.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
println!("{}", handle.get_long_limit());

pub fn get_current_short_limit(&self) -> u32[src]

Gets the current remaining short limit as an i32.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
println!("{}", handle.get_current_short_limit());

pub fn get_current_long_limit(&self) -> u32[src]

Gets the current remaining long limit as an i32.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
println!("{}", handle.get_current_long_limit());

pub fn get_sauce(&self, image_path: &str) -> Result<Vec<Sauce>>[src]

Returns a Result of either a vector of Sauce objects, which contain potential sources for the input file, or a SauceError.

Arguments

  • image_path - A string slice that contains the url of the image you wish to look up.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
handle.get_sauce("./tests/test.jpg");

Errors

If there was a problem forming a URL, reading a file, making a request, or parsing the returned JSON, an error will be returned. Furthermore, if you pass a link in which SauceNAO returns an error code, an error containing the code and message will be returned.

pub fn get_sauce_as_pretty_json(&self, image_path: &str) -> Result<String>[src]

Returns a string representing a vector of Sauce objects as a serialized JSON, or an error.

Arguments

  • image_path - A string slice that contains the url of the image you wish to look up.

Example

use rustnao::Handler;
let handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(999));
handle.get_sauce_as_pretty_json("https://i.imgur.com/W42kkKS.jpg");

Errors

If there was a problem forming a URL, reading a file, making a request, or parsing the returned JSON, an error will be returned. Furthermore, if you pass a link in which SauceNAO returns an error code, an error containing the code and message will be returned.

pub fn get_sauce_as_json(&self, image_path: &str) -> Result<String>[src]

Returns a string representing a vector of Sauce objects as a serialized JSON, or an error.

Arguments

  • image_path - A string slice that contains the url of the image you wish to look up.

Example

use rustnao::Handler;
let mut handle = Handler::new("your_saucenao_api_key", Some(0), None, None, Some(999), Some(5));
handle.get_sauce_as_json("https://i.imgur.com/W42kkKS.jpg");

Errors

If there was a problem forming a URL, reading a file, making a request, or parsing the returned JSON, an error will be returned. Furthermore, if you pass a link in which SauceNAO returns an error code, an error containing the code and message will be returned.

Trait Implementations

impl Clone for Handler[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Handler[src]

Auto Trait Implementations

impl Send for Handler

impl !Sync for Handler

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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