Crate rustnao

source ·
Expand description

§RustNAO

A Rust implementation of a wrapper for the SauceNAO API.

Build Status crates.io link Documentation

§Installation

Add the following to your Cargo.toml file:

[dependencies]
rustnao = "0.3.1"

§Examples

Here’s a simple example:

use rustnao::{Handler, HandlerBuilder, Sauce, Result};

fn main() {
    let api_key = "your_api_key";
    let file = "https://i.imgur.com/W42kkKS.jpg";

    // Specifying our key, only want to see Pixiv and Sankaku using a mask, and 15 results at most
    let handle = HandlerBuilder::default().api_key(api_key).db_mask([Handler::PIXIV, Handler::SANKAKU_CHANNEL].to_vec()).num_results(15).build();

    // Set the minimum similarity to 45.
    handle.set_min_similarity(45);

    // Returns a vector of Sauce objects if successful
    let result : Result<Vec<Sauce>> = handle.get_sauce(file, None, None);

    // Or perhaps you prefer a JSON output
    let result_json : Result<String> = handle.get_sauce_as_pretty_json(file, None, None);

    // Or maybe you wish to only get 5 results with a min similarity of 50.0
    let result_json_filtered : Result<String> = handle.get_sauce_as_pretty_json(file, Some(5), Some(50 as f64));
}

Structs§

  • An error that can occur while interacting to the SauceNAO API.
  • A handler struct to make SauceNAO API calls with.
  • A builder to create a Handler for RustNAO usage.
  • A Sauce struct contains one result from a API call made by the Handler.

Enums§

  • The specific type of error that can occur.

Traits§

  • A trait to convert to JSON and pretty JSON strings.

Type Aliases§

  • A type alias for handling errors related to rustnao.