Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

A low level Client for the hydrus API. It provides basic abstraction over the REST api.

Implementations§

Source§

impl Client

Source

pub fn builder() -> ClientBuilder

Returns a builder for the client

Source

pub fn new<S: AsRef<str>>(url: S, access_key: S) -> Self

Creates a new client to start requests against the hydrus api.

Source

pub async fn api_version(&self) -> Result<ApiVersionResponse>

Returns the current API version. It’s being incremented every time the API changes.

Source

pub async fn session_key(&self) -> Result<SessionKeyResponse>

Creates a new session key

Source

pub async fn verify_access_key(&self) -> Result<VerifyAccessKeyResponse>

Verifies if the access key is valid and returns some information about its permissions

Source

pub async fn get_services(&self) -> Result<GetServicesResponse>

Returns the list of tag and file services of the client

Source

pub async fn add_file<S: ToString + Debug>( &self, path: S, ) -> Result<AddFileResponse>

Adds a file to hydrus

Source

pub async fn add_binary_file(&self, data: Vec<u8>) -> Result<AddFileResponse>

Adds a file from binary data to hydrus

Source

pub async fn delete_files( &self, files: FileSelection, service: FileServiceSelection, reason: Option<String>, ) -> Result<()>

Moves files with matching hashes to the trash

Source

pub async fn undelete_files( &self, files: FileSelection, service: FileServiceSelection, ) -> Result<()>

Pulls files out of the trash by hash

Source

pub async fn archive_files( &self, files: FileSelection, service: FileServiceSelection, ) -> Result<()>

Moves files from the inbox into the archive

Source

pub async fn unarchive_files( &self, files: FileSelection, service: FileServiceSelection, ) -> Result<()>

Moves files from the archive into the inbox

Source

pub async fn clean_tags(&self, tags: Vec<String>) -> Result<CleanTagsResponse>

Returns the list of tags as the client would see them in a human friendly order

Source

pub async fn add_tags(&self, request: AddTagsRequest) -> Result<()>

Adds tags to files with the given hashes

Source

pub async fn search_tags<S: ToString + Debug>( &self, query: S, options: TagSearchOptions, ) -> Result<SearchTagsResponse>

Searches for tags by name

Source

pub async fn search_files( &self, query: Vec<SearchQueryEntry>, options: FileSearchOptions, ) -> Result<SearchFilesResponse>

Searches for files

Source

pub async fn search_file_hashes( &self, query: Vec<SearchQueryEntry>, options: FileSearchOptions, ) -> Result<SearchFileHashesResponse>

Searches for file hashes

Source

pub async fn get_file_metadata<M: FileMetadataType>( &self, file_ids: Vec<u64>, hashes: Vec<String>, ) -> Result<FileMetadataResponse<M>>

Returns the metadata for a given list of file_ids or hashes

Source

pub async fn get_file_metadata_by_identifier<M: FileMetadataType>( &self, id: FileIdentifier, ) -> Result<M::Response>

Returns the metadata for a single file identifier

Source

pub async fn get_file(&self, id: FileIdentifier) -> Result<FileRecord>

Returns the bytes of a file from hydrus

Source

pub async fn get_url_files<S: AsRef<str> + Debug>( &self, url: S, ) -> Result<GetUrlFilesResponse>

Returns all files associated with the given url

Source

pub async fn get_url_info<S: AsRef<str> + Debug>( &self, url: S, ) -> Result<GetUrlInfoResponse>

Returns information about the given url

Source

pub async fn add_url(&self, request: AddUrlRequest) -> Result<AddUrlResponse>

Adds an url to hydrus, optionally with additional tags and a destination page

Source

pub async fn associate_urls( &self, urls: Vec<String>, hashes: Vec<String>, ) -> Result<()>

Associates urls with the given file hashes

Source

pub async fn disassociate_urls( &self, urls: Vec<String>, hashes: Vec<String>, ) -> Result<()>

Disassociates urls with the given file hashes

Source

pub async fn set_notes( &self, id: FileIdentifier, notes: HashMap<String, String>, ) -> Result<()>

Sets the notes for the file

Source

pub async fn delete_notes( &self, id: FileIdentifier, note_names: Vec<String>, ) -> Result<()>

Deletes the notes of a file

Source

pub async fn get_pages(&self) -> Result<GetPagesResponse>

Returns all pages of the client

Source

pub async fn get_page_info<S: AsRef<str> + Debug>( &self, page_key: S, ) -> Result<GetPageInfoResponse>

Returns information about a single page

Source

pub async fn focus_page<S: ToString + Debug>(&self, page_key: S) -> Result<()>

Focuses a page in the client

Source

pub async fn add_files_to_page<S: ToString + Debug>( &self, page_key: S, file_ids: Vec<u64>, hashes: Vec<String>, ) -> Result<()>

Adds files to a page

Source

pub async fn get_cookies<S: AsRef<str> + Debug>( &self, domain: S, ) -> Result<GetCookiesResponse>

Returns all cookies for the given domain

Source

pub async fn set_cookies( &self, cookies: Vec<[OptionalStringNumber; 5]>, ) -> Result<()>

Sets some cookies for some websites. Each entry needs to be in the format [<name>, <value>, <domain>, <path>, <expires>] with the types [String, String, String, String, u64]

Source

pub async fn set_user_agent<S: ToString + Debug>( &self, user_agent: S, ) -> Result<()>

Sets the user agent that is being used for every request hydrus starts

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T