[][src]Struct rustnao::Handler

pub struct Handler { /* fields omitted */ }

A handler struct to make SauceNAO API calls with.

Example

use rustnao::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
handle.get_sauce("https://i.imgur.com/W42kkKS.jpg", None, None);

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]

NOTE: May likely be deprecated in version 0.3. Preferably, use the builder pattern instead.

Creates a new Handler object. By default, SauceNAO sets the short limit is set to 30 seconds, and the long limit is set to 24 hours. Furthermore, by default on all get_sauce searches, the minimum simliarity is 0.0, and empty URL searches are not filtered out.

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 u32 values representing a mask for which database indices you wish to have enabled.
  • db_mask_i - A Option for a vector of u32 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 default number of results you wish returned (you can change this number per-search if you want). 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, min_similarity: T)[src]

Sets the minimum similarity threshold for get_sauce. By default this is 0.0.

Arguments

  • min_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::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
handle.set_min_similarity(50);

pub fn set_empty_filter(&self, enabled: bool)[src]

Sets the whether empty URL results should be automatically filtered for get_sauce.

Arguments

  • enabled - Represents whether filter should be enabled or not. By default, this is disabled.

Example

use rustnao::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
handle.set_empty_filter(true);

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

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

Example

use rustnao::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
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::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
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::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
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::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
println!("{}", handle.get_current_long_limit());

pub fn get_sauce(
    &self,
    image_path: &str,
    num_results: Option<u32>,
    min_similarity: Option<f64>
) -> 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.
  • num_results - An Option containing a u32 to specify the number of results you wish to get for this specific search. If this is None, it will default to whatever was originally set in the Handler when it was initalized. This can be at most 999.
  • min_similarity - An Option containing a f64 to specify the minimum similarity you wish to meet for a result to show up for this specific search. If this is None, it will default to whatever was originally set in the Handler when it was initalized.

Example

use rustnao::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
handle.get_sauce("./tests/test.jpg", None, None);

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,
    num_results: Option<u32>,
    min_similarity: Option<f64>
) -> 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.
  • num_results - An Option containing a u32 to specify the number of results you wish to get for this specific search. If this is None, it will default to whatever was originally set in the Handler when it was initalized.
  • min_similarity - An Option containing a f64 to specify the minimum similarity you wish to meet for a result to show up for this specific search. If this is None, it will default to whatever was originally set in the Handler when it was initalized.

Example

use rustnao::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
handle.get_sauce_as_pretty_json("https://i.imgur.com/W42kkKS.jpg", None, None);

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,
    num_results: Option<u32>,
    min_similarity: Option<f64>
) -> 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.
  • num_results - An Option containing a u32 to specify the number of results you wish to get for this specific search. If this is None, it will default to whatever was originally set in the Handler when it was initalized.
  • min_similarity - An Option containing a f64 to specify the minimum similarity you wish to meet for a result to show up for this specific search. If this is None, it will default to whatever was originally set in the Handler when it was initalized.

Example

use rustnao::HandlerBuilder;
let handle = HandlerBuilder::new().api_key("your_api_key").num_results(999).db(999).build();
handle.get_sauce_as_json("https://i.imgur.com/W42kkKS.jpg", None, None);

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 Unpin for Handler

impl !Sync for Handler

impl UnwindSafe for Handler

impl !RefUnwindSafe for Handler

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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