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

```rust use std::env; use hydrusapi::apicore::searchingandfetchingfiles::FileSearchLocation; use hydrusapi::wrapper::tag::Tag; use hydrusapi::wrapper::service::ServiceName; use hydrusapi::wrapper::hydrusfile::FileStatus; use hydrusapi::wrapper::page::PageIdentifier; use hydrusapi::wrapper::builders::searchbuilder::SortType; use hydrusapi::wrapper::builders::orchainbuilder::OrChainBuilder; use hydrusapi::wrapper::builders::tag_builder::{ SystemTagBuilder, Comparator };

[tokio::main]

async fn main() { let hydrusurl = env::var("HYDRUSURL").unwrap(); let accesskey = env::var("HYDRUSACCESS_KEY").unwrap();

let hydrus = Hydrus::new(Client::new(hydrus_url, access_key));
let files = hydrus.search()
    .add_tag(Tag::from("character:megumin"))
    .add_tag(SystemTagBuilder::new().archive().build())
    .add_tag(SystemTagBuilder::new().number_of_tags(Comparator::Greater, 12).build())
    .add_or_chain(
        OrChainBuilder::new()
            .add_tag("summer".into())
            .add_tag("winter".into())
            .build(),
    )
    .sort(SortType::ModifiedTime)
    .run().await.unwrap();

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

let url = hydrus.import()
    .url("https://www.pixiv.net/member_illust.php?illust_id=83406361&mode=medium")
    .page(PageIdentifier::name("My Import Page"))
    .add_additional_tag(ServiceName::my_tags(), Tag::from("character:megumin"))
    .show_page(true)
    .run().await.unwrap();

} ```

Example with Client

```rust use hydrusapi::Client; use hydrusapi::paths::adding_tags::{AddTagsRequestBuilder, TagAction}; use std::env;

[tokio::main]

async fn main() { Client::new( env::var("HYDRUSURL").unwrap(), env::var("HYDRUSACCESSKEY").unwrap(), ); // let's first import a file let hash = client.addfile("/path/to/my/file").await.unwrap().hash;

// and now let's add tags to it
let request = AddTagsRequestBuilder::default()
    .add_hash(hash)
    // for each tag the service has to be specified
    .add_tags("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("my tags", "rain", TagAction::DeleteFromLocalService)
    .build();

client.add_tags(request).await.unwrap();

} ```

License

Apache-2.0