A rust wrapper for the hydrus client api
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Julius Riegel dc685bcd63
Merge pull request #18 from Trivernis/develop
11 months ago
.github/workflows Fix publishing command 1 year ago
.idea Add access management functions 2 years ago
src Fix search query being internally tagged 11 months ago
tests Control response content type via Accept header 12 months ago
.gitignore Add dotenv support for tests 1 year ago
Cargo.toml Fix search query being internally tagged 11 months ago
LICENSE Create LICENSE 2 years ago
README.md Change tag import wrapper to use service identifiers instead of names 1 year ago


Hydrus Rust API

This is a WIP Rust Wrapper for the Hydrus Client API. The official API documentation can be found here.

Example with Wrapper

use std::env;
use hydrus_api::api_core::searching_and_fetching_files::FileSearchLocation;
use hydrus_api::wrapper::tag::Tag;
use hydrus_api::wrapper::service::ServiceName;
use hydrus_api::wrapper::hydrus_file::FileStatus;
use hydrus_api::wrapper::page::PageIdentifier;
use hydrus_api::wrapper::builders::search_builder::SortType;
use hydrus_api::wrapper::builders::or_chain_builder::OrChainBuilder;
use hydrus_api::wrapper::builders::tag_builder::{
    SystemTagBuilder, Comparator

async fn main() {
    let hydrus_url = env::var("HYDRUS_URL").unwrap();
    let access_key = env::var("HYDRUS_ACCESS_KEY").unwrap();
    let hydrus = Hydrus::new(Client::new(hydrus_url, access_key));
    let files = hydrus.search()
        .add_tag(SystemTagBuilder::new().number_of_tags(Comparator::Greater, 12).build())

    for mut file in files {
        file.add_tags(ServiceName::my_tags().into(), vec![Tag::from("ark mage")]).await.unwrap();

    let url = hydrus.import()
        .page(PageIdentifier::name("My Import Page"))
        .add_additional_tag(ServiceName::my_tags().into(), Tag::from("character:megumin"))

Example with Client

use hydrus_api::Client;
use hydrus_api::paths::adding_tags::{AddTagsRequestBuilder, TagAction};
use std::env;
use hydrus_api::api_core::common::ServiceIdentifier;

async fn main() {
    // let's first import a file
    let hash = client.add_file("/path/to/my/file").await.unwrap().hash;
    // and now let's add tags to it
    let request = AddTagsRequestBuilder::default()
        // for each tag the service has to be specified
        .add_tags(ServiceIdentifier::name("my tags"), vec!["beach".into(), "summer".into()])
        // with tag actions tags can also be removed. It's especially useful for the PTR
        .add_tag_with_action(ServiceIdentifier::name("my tags"), "rain", TagAction::DeleteFromLocalService)