Struct LinkDingClient

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

A sync client for the LinkDing API.

This client is used to interact with the LinkDing API. It provides methods for managing bookmarks and tags, the full capability of the LinkDing API.

§Example

use linkding::{LinkDingClient, LinkDingError, CreateBookmarkBody};

fn main() -> Result<(), LinkDingError> {
    let client = LinkDingClient::new("https://linkding.local:9090", "YOUR_API_TOKEN");
    let new_bookmark = CreateBookmarkBody {
        url: "https://example.com".to_string(),
        ..Default::default()
    };
    let bookmark = client.create_bookmark(new_bookmark)?;
    println!("Bookmark created: {:?}", bookmark);
    client.delete_bookmark(bookmark.id)?;
    println!("Bookmark deleted");
    Ok(())
}

Implementations§

Source§

impl LinkDingClient

Source

pub fn new(url: &str, token: &str) -> Self

Source

pub fn list_bookmarks( &self, args: ListBookmarksArgs, ) -> Result<ListBookmarksResponse, LinkDingError>

List unarchived bookmarks

Source

pub fn list_archived_bookmarks( &self, args: ListBookmarksArgs, ) -> Result<ListBookmarksResponse, LinkDingError>

List archived bookmarks

Source

pub fn get_bookmark(&self, id: i32) -> Result<Bookmark, LinkDingError>

Get a bookmark by ID

Source

pub fn check_url(&self, url: &str) -> Result<CheckUrlResponse, LinkDingError>

Check if a URL has been bookmarked

If the URL has already been bookmarked this will return the bookmark data, otherwise the bookmark data will be None. The metadata of the webpage will always be returned.

Source

pub fn create_bookmark( &self, body: CreateBookmarkBody, ) -> Result<Bookmark, LinkDingError>

Create a bookmark

If the bookmark already exists, it will be updated with the new data passed in the body parameter.

Source

pub fn update_bookmark( &self, id: i32, body: UpdateBookmarkBody, ) -> Result<Bookmark, LinkDingError>

Update a bookmark

Pass only the fields you want to update in the body parameter.

Source

pub fn archive_bookmark(&self, id: i32) -> Result<bool, LinkDingError>

Archive a bookmark

Source

pub fn unarchive_bookmark(&self, id: i32) -> Result<bool, LinkDingError>

Take a bookmark out of the archive

Source

pub fn delete_bookmark(&self, id: i32) -> Result<bool, LinkDingError>

Delete a bookmark

Source

pub fn list_tags( &self, args: ListTagsArgs, ) -> Result<ListTagsResponse, LinkDingError>

List tags

Source

pub fn get_tag(&self, id: i32) -> Result<TagData, LinkDingError>

Get a tag by ID

Source

pub fn create_tag(&self, name: &str) -> Result<TagData, LinkDingError>

Create a tag

Source

pub fn get_user_profile(&self) -> Result<UserProfile, LinkDingError>

Get the user’s profile

Trait Implementations§

Source§

impl Clone for LinkDingClient

Source§

fn clone(&self) -> LinkDingClient

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 LinkDingClient

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 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, dst: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.