Struct wallabag_api::Client

source ·
pub struct Client { /* private fields */ }
Expand description

The main thing that provides all the methods for interacting with the Wallabag API.

Implementations§

source§

impl Client

source

pub fn new(config: Config) -> Self

Build a new client given the configuration.

source

pub async fn check_urls_exist<T: Into<String>>( &mut self, urls: Vec<T> ) -> ClientResult<ExistsInfo>

Check if a list of urls already have entries. This is more efficient if you want to batch check urls since only a single request is required. Returns a hashmap where the urls given are the keys and the values are either:

  • None: no existing entry corresponding to the url
  • Some(ID): an entry exists and here’s the ID
source

pub async fn check_url_exists<T: Into<String>>( &mut self, url: T ) -> ClientResult<Option<ID>>

Check if a url already has a corresponding entry. Returns None if not existing or the ID of the entry if it does exist.

source

pub async fn create_entry( &mut self, new_entry: &NewEntry ) -> ClientResult<Entry>

Create a new entry. See docs for NewEntry for more information.

source

pub async fn update_entry<T: Into<ID>>( &mut self, id: T, entry: &PatchEntry ) -> ClientResult<Entry>

Update entry. To leave an editable field unchanged, set to None.

source

pub async fn reload_entry<T: Into<ID>>(&mut self, id: T) -> ClientResult<Entry>

Reload entry. This tells the server to re-fetch content from the url (or origin url?) and use the result to refresh the entry contents.

This returns Err(ClientError::NotModified) if the server either could not refresh the contents, or the content does not get modified.

source

pub async fn get_entry<T: Into<ID>>(&mut self, id: T) -> ClientResult<Entry>

Get an entry by id.

source

pub async fn delete_entry<T: Into<ID>>(&mut self, id: T) -> ClientResult<Entry>

Delete an entry by id.

source

pub async fn update_annotation( &mut self, annotation: &Annotation ) -> ClientResult<Annotation>

Update an annotation.

source

pub async fn create_annotation<T: Into<ID>>( &mut self, entry_id: T, annotation: &NewAnnotation ) -> ClientResult<Annotation>

Create a new annotation on an entry.

source

pub async fn delete_annotation<T: Into<ID>>( &mut self, id: T ) -> ClientResult<Annotation>

Delete an annotation by id

source

pub async fn get_annotations<T: Into<ID>>( &mut self, id: T ) -> ClientResult<Annotations>

Get all annotations for an entry (by id).

source

pub async fn get_entries(&mut self) -> ClientResult<Entries>

Get all entries.

source

pub async fn get_entries_with_filter( &mut self, filter: &EntriesFilter ) -> ClientResult<Entries>

Get all entries, filtered by filter parameters.

source

pub async fn get_entries_page( &mut self, filter: &EntriesFilter, page_number: u32 ) -> ClientResult<EntriesPage>

Get a page of entries, specified by page number. Useful when the expected list of results is very large and you don’t want to wait too long before getting a subset of the entries. Will return a not found error if page_number is out of bounds.

source

pub async fn export_entry<T: Into<ID>>( &mut self, entry_id: T, fmt: Format ) -> ClientResult<String>

Get an export of an entry in a particular format.

source

pub async fn get_tags_for_entry<T: Into<ID>>( &mut self, entry_id: T ) -> ClientResult<Tags>

Get a list of all tags for an entry by entry id.

source

pub async fn add_tags_to_entry<T: Into<ID>, U: Into<String>>( &mut self, entry_id: T, tags: Vec<U> ) -> ClientResult<Entry>

Add tags to an entry by entry id. Idempotent operation. No problems if tags list is empty.

source

pub async fn delete_tag_from_entry<T: Into<ID>, U: Into<ID>>( &mut self, entry_id: T, tag_id: U ) -> ClientResult<Entry>

Delete a tag (by id) from an entry (by id). Returns err 404 if entry or tag not found. Idempotent. Removing a tag that exists but doesn’t exist on the entry completes without error.

source

pub async fn get_tags(&mut self) -> ClientResult<Tags>

Get a list of all tags.

source

pub async fn delete_tag<T: Into<ID>>(&mut self, id: T) -> ClientResult<Tag>

Permanently delete a tag by id. This removes the tag from all entries. Appears to return success if attempting to delete a tag by id that exists on the server but isn’t accessible to the user.

source

pub async fn delete_tag_by_label<T: Into<String>>( &mut self, label: T ) -> ClientResult<DeletedTag>

Permanently delete a tag by label (tag names). This also exhibits the privacy breaching behaviour of returning tag info of other users’ tags. Also, labels aren’t necessarily unique across a wallabag installation. The server should filter by tags belonging to a user in the same db query.

Note: this allows deleting a tag with a comma by label.

source

pub async fn delete_tags_by_label( &mut self, tags: Vec<TagString> ) -> ClientResult<Vec<DeletedTag>>

Permanently batch delete tags by labels (tag names). Returns not found if all labels not found. If at least one found, then returns ok. For some reason, (at least the framabag instance) the server returns success and the tag data on attempting to delete for innaccessible tags (tags by other users?).

This method requires that tag names not contain commas. If you need to delete a tag containing a comma, use delete_tag_by_label instead.

Returns a list of tags that were deleted (sans IDs). Returns 404 not found only if all tags were not found.

source

pub async fn get_api_version(&mut self) -> ClientResult<String>

Get the API version. Probably not useful because if the version isn’t v2 then this library won’t work anyway.

source

pub async fn get_user(&mut self) -> ClientResult<User>

Get the currently logged in user information.

source

pub async fn register_user( &mut self, info: &RegisterInfo ) -> ClientResult<NewlyRegisteredInfo>

Register a user and create a client.

Trait Implementations§

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§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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> 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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> 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