Deprecate service_names_with_tags on file wrapper

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/9/head
trivernis 2 years ago
parent b7f902e3dd
commit 53f29a33d5
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -54,7 +54,10 @@ pub struct FileMetadataInfo {
pub is_local: bool,
pub is_trashed: bool,
pub known_urls: Vec<String>,
#[deprecated]
pub service_names_to_statuses_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
pub service_keys_to_statuses_to_tags: HashMap<String, HashMap<String, Vec<String>>>,
#[deprecated]
pub service_names_to_statuses_to_display_tags: HashMap<String, HashMap<String, Vec<String>>>,
pub service_keys_to_statuses_to_display_tags: HashMap<String, HashMap<String, Vec<String>>>,
}

@ -24,7 +24,8 @@
//! let files = hydrus.search()
//! .add_tag(Tag::from("character:megumin"))
//! .add_tag(SystemTagBuilder::new().archive().build())
//! .add_tag(SystemTagBuilder::new().tag_namespace_as_number("page", Comparator::Equal, 5).negate().build())
//! .add_tag(SystemTagBuilder::new()
//! .tag_namespace_as_number("page", Comparator::Equal, 5).negate().build())
//! .add_or_chain(
//! OrChainBuilder::new()
//! .add_tag("summer".into())

@ -239,11 +239,15 @@ impl HydrusFile {
self.client.disassociate_urls(urls, vec![hash]).await
}
/// Returns map mapping lists of tags to services
pub async fn services_with_tags(&mut self) -> Result<HashMap<ServiceName, Vec<Tag>>> {
/// Returns map mapping lists of tags to services.
///
/// Deprecation: Use [HydrusFile::services_with_tags] instead.
#[deprecated(note = "Deprecated in the official API. Use services_with_tags instead.")]
pub async fn service_names_with_tags(&mut self) -> Result<HashMap<ServiceName, Vec<Tag>>> {
let metadata = self.metadata().await?;
let mut tag_mappings = HashMap::new();
#[allow(deprecated)]
for (service, status_tags) in &metadata.service_names_to_statuses_to_tags {
let mut tag_list = Vec::new();
@ -256,6 +260,23 @@ impl HydrusFile {
Ok(tag_mappings)
}
/// Returns a mapping with service ids mapped to tags
pub async fn services_with_tags(&mut self) -> Result<HashMap<ServiceIdentifier, Vec<Tag>>> {
let metadata = self.metadata().await?;
let mut tag_mappings = HashMap::new();
for (service, status_tags) in &metadata.service_keys_to_statuses_to_tags {
let mut tag_list = Vec::new();
for (_, tags) in status_tags {
tag_list.append(&mut tags.into_iter().map(|t| t.into()).collect())
}
tag_mappings.insert(ServiceIdentifier::Key(service.clone()), tag_list);
}
Ok(tag_mappings)
}
/// Returns a list of all tags assigned to the file
pub async fn tags(&mut self) -> Result<Vec<Tag>> {
let mut tag_list = Vec::new();

Loading…
Cancel
Save