Change wrapped search to operate on hashes instead

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/17/head
trivernis 2 years ago
parent d4c4d9465f
commit b7295fb7bc
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,6 @@
[package] [package]
name = "hydrus-api" name = "hydrus-api"
version = "0.9.1" version = "0.9.2"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"

@ -123,11 +123,11 @@ impl SearchBuilder {
.map(|c| SearchQueryEntry::OrChain(c.into_string_list())) .map(|c| SearchQueryEntry::OrChain(c.into_string_list()))
.collect(), .collect(),
); );
let response = client.search_files(entries, self.options).await?; let response = client.search_file_hashes(entries, self.options).await?;
let files = response let files = response
.file_ids .hashes
.into_iter() .into_iter()
.map(|id| HydrusFile::from_id(client.clone(), id)) .map(|hash| HydrusFile::from_hash(client.clone(), hash))
.collect(); .collect();
Ok(files) Ok(files)

@ -43,10 +43,10 @@ pub struct HydrusFile {
} }
impl HydrusFile { impl HydrusFile {
pub(crate) fn from_id(client: Client, id: u64) -> Self { pub(crate) fn from_hash<S: ToString>(client: Client, hash: S) -> Self {
Self { Self {
client, client,
id: FileIdentifier::ID(id), id: FileIdentifier::Hash(hash.to_string()),
status: FileStatus::Unknown, status: FileStatus::Unknown,
metadata: None, metadata: None,
} }

Loading…
Cancel
Save