[][src]Struct rustnao::Sauce

pub struct Sauce {
    pub ext_urls: Vec<String>,
    pub title: Option<String>,
    pub site: String,
    pub index: u32,
    pub index_id: u32,
    pub similarity: f32,
    pub thumbnail: String,
    pub additional_fields: Option<Value>,
}

A Sauce struct contains one result from a API call made by the Handler.

Example

use rustnao::{Sauce, HandlerBuilder};
let mut handle = HandlerBuilder::new().api_key("your_api_key").build();
let result : rustnao::Result<Vec<Sauce>> = handle.get_sauce("https://i.pximg.net/img-master/img/2019/02/10/03/11/39/73095123_p0_master1200.jpg", None, None);

Fields

ext_urls: Vec<String>

A Vec of Strings representing the external URLs for the image

title: Option<String>

An optional String to represent the title of the image

site: String

A string to represent the site the image is from

index: u32

The official index on SauceNAO for the index the site corresponds to

index_id: u32

The index rerturned by the SauceNAO API. Usually this is equal to the index but sometimes it is different (see Sankaku, for example)

similarity: f32

The similarity the image has with the guess

thumbnail: String

A string representing the URL of the thumbnail

additional_fields: Option<Value>

Any additional fields that are specific to the source

Methods

impl Sauce[src]

pub fn has_empty_url(&self) -> bool[src]

Returns whether the Sauce struct contains an empty ext_url field.

Example

use rustnao::{HandlerBuilder, Sauce};
let file = "https://i.imgur.com/W42kkKS.jpg";
let mut handle = HandlerBuilder::new().api_key("your_api_key").build();
handle.set_min_similarity(45);
let result = handle.get_sauce(file, None, None);
if result.is_ok() {
	let res : Vec<Sauce> = result.unwrap().into_iter().filter(|sauce| sauce.has_empty_url()).collect();
	for i in res {
		println!("{:?}", i);
	}
}
else {
	println!("Failed to make a query.");
}

Trait Implementations

impl Debug for Sauce[src]

impl Serialize for Sauce[src]

Auto Trait Implementations

impl Send for Sauce

impl Unpin for Sauce

impl Sync for Sauce

impl UnwindSafe for Sauce

impl RefUnwindSafe for Sauce

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