Change wrapped search to operate on hashes instead

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

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

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

@ -43,10 +43,10 @@ pub struct 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 {
client,
id: FileIdentifier::ID(id),
id: FileIdentifier::Hash(hash.to_string()),
status: FileStatus::Unknown,
metadata: None,
}

Loading…
Cancel
Save