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
impl LinkDingClient
pub fn new(url: &str, token: &str) -> Self
Sourcepub fn list_bookmarks(
&self,
args: ListBookmarksArgs,
) -> Result<ListBookmarksResponse, LinkDingError>
pub fn list_bookmarks( &self, args: ListBookmarksArgs, ) -> Result<ListBookmarksResponse, LinkDingError>
List unarchived bookmarks
Sourcepub fn list_archived_bookmarks(
&self,
args: ListBookmarksArgs,
) -> Result<ListBookmarksResponse, LinkDingError>
pub fn list_archived_bookmarks( &self, args: ListBookmarksArgs, ) -> Result<ListBookmarksResponse, LinkDingError>
List archived bookmarks
Sourcepub fn get_bookmark(&self, id: i32) -> Result<Bookmark, LinkDingError>
pub fn get_bookmark(&self, id: i32) -> Result<Bookmark, LinkDingError>
Get a bookmark by ID
Sourcepub fn check_url(&self, url: &str) -> Result<CheckUrlResponse, LinkDingError>
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.
Sourcepub fn create_bookmark(
&self,
body: CreateBookmarkBody,
) -> Result<Bookmark, LinkDingError>
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.
Sourcepub fn update_bookmark(
&self,
id: i32,
body: UpdateBookmarkBody,
) -> Result<Bookmark, LinkDingError>
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.
Sourcepub fn archive_bookmark(&self, id: i32) -> Result<bool, LinkDingError>
pub fn archive_bookmark(&self, id: i32) -> Result<bool, LinkDingError>
Archive a bookmark
Sourcepub fn unarchive_bookmark(&self, id: i32) -> Result<bool, LinkDingError>
pub fn unarchive_bookmark(&self, id: i32) -> Result<bool, LinkDingError>
Take a bookmark out of the archive
Sourcepub fn delete_bookmark(&self, id: i32) -> Result<bool, LinkDingError>
pub fn delete_bookmark(&self, id: i32) -> Result<bool, LinkDingError>
Delete a bookmark
List tags
Sourcepub fn create_tag(&self, name: &str) -> Result<TagData, LinkDingError>
pub fn create_tag(&self, name: &str) -> Result<TagData, LinkDingError>
Create a tag
Sourcepub fn get_user_profile(&self) -> Result<UserProfile, LinkDingError>
pub fn get_user_profile(&self) -> Result<UserProfile, LinkDingError>
Get the user’s profile
Trait Implementations§
Source§impl Clone for LinkDingClient
impl Clone for LinkDingClient
Source§fn clone(&self) -> LinkDingClient
fn clone(&self) -> LinkDingClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more