From 382019c4bebd78a25cd412c07fdb1bdc30d27a8e Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 31 Jul 2021 12:57:25 +0200 Subject: [PATCH] Update docs for new tag builder Signed-off-by: trivernis --- README.md | 9 ++++++++- src/lib.rs | 7 ++++++- tests/wrapper/test_tags.rs | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a88b9d..4977b61 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ 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::tag_builder::{ + SystemTagBuilder, Comparator +}; #[tokio::main] async fn main() { @@ -30,7 +33,11 @@ async fn main() { let access_key = env::var("HYDRUS_ACCESS_KEY").unwrap(); let hydrus = Hydrus::new(Client::new(hydrus_url, access_key)); - let files = hydrus.search(FileSearchLocation::Archive,vec![Tag::from("character:megumin")]).await.unwrap(); + let files = hydrus.search(FileSearchLocation::Archive,vec![ + Tag::from("character:megumin"), + SystemTagBuilder::new().archive().build(), + SystemTagBuilder::new().number_of_tags(Comparator::Greater, 12).build(), + ]).await.unwrap(); for mut file in files { file.add_tags(ServiceName::my_tags(), vec![Tag::from("ark mage")]).await.unwrap(); diff --git a/src/lib.rs b/src/lib.rs index c66d8ec..cbf98e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,13 +12,18 @@ //! use hydrus_api::wrapper::service::ServiceName; //! use hydrus_api::wrapper::hydrus_file::FileStatus; //! use hydrus_api::wrapper::page::PageIdentifier; +//! use hydrus_api::wrapper::builders::tag_builder::{SystemTagBuilder, Comparator}; //! //! # #[tokio::test] //! # async fn doctest() { //! 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(vec![Tag::from("character:megumin")]).await.unwrap(); +//! let files = hydrus.search(vec![ +//! Tag::from("character:megumin"), +//! SystemTagBuilder::new().archive().build(), +//! SystemTagBuilder::new().tag_namespace_as_number("page", Comparator::Equal, 5).negate().build(), +//! ]).await.unwrap(); //! //! for mut file in files { //! file.add_tags(ServiceName::my_tags(), vec![Tag::from("ark mage")]).await.unwrap(); diff --git a/tests/wrapper/test_tags.rs b/tests/wrapper/test_tags.rs index d294ebb..e51e3a6 100644 --- a/tests/wrapper/test_tags.rs +++ b/tests/wrapper/test_tags.rs @@ -21,6 +21,12 @@ async fn it_returns_everything() { retrieve_single_tag(tag).await.unwrap(); } +#[tokio::test] +async fn it_returns_everything_negated() { + let tag = SystemTagBuilder::new().everything().negate().build(); + retrieve_single_tag(tag).await.unwrap(); +} + #[tokio::test] async fn it_returns_the_inbox() { let tag = SystemTagBuilder::new().inbox().build();