pub struct BookmarkStore { /* private fields */ }Expand description
Persistent bookmark storage backed by a [sled::Tree] in an open [sled::Db].
The tree name is "bookmarks". Keys are URL byte strings; values are an internal
binary encoding of title, favorite bit, and timestamp (see Bookmark).
Implementations§
Source§impl BookmarkStore
impl BookmarkStore
Sourcepub fn open(db: &Db) -> Result<Self>
pub fn open(db: &Db) -> Result<Self>
Opens the bookmarks tree in db, creating it if it does not exist.
Sourcepub fn add(&self, url: &str, title: &str) -> Result<()>
pub fn add(&self, url: &str, title: &str) -> Result<()>
Inserts a new bookmark for url with the given title, or overwrites the existing entry.
The bookmark is stored as not favorited with a fresh Bookmark::created_at_ms.
Sourcepub fn toggle_favorite(&self, url: &str) -> Result<bool>
pub fn toggle_favorite(&self, url: &str) -> Result<bool>
Flips the favorite flag for the bookmark at url and returns the new value.
If the URL is missing or the stored value cannot be decoded, returns Ok(false) without
changing storage.
Sourcepub fn is_favorite(&self, url: &str) -> bool
pub fn is_favorite(&self, url: &str) -> bool
Returns whether the bookmark at url is marked as a favorite.
Missing or corrupt entries are treated as not favorited.
Sourcepub fn list_all(&self) -> Vec<Bookmark>
pub fn list_all(&self) -> Vec<Bookmark>
Returns every bookmark, ordered by Bookmark::created_at_ms descending (newest first).
Sourcepub fn list_favorites(&self) -> Vec<Bookmark>
pub fn list_favorites(&self) -> Vec<Bookmark>
Returns only bookmarks with Bookmark::is_favorite set, in the same order as Self::list_all.
Trait Implementations§
Source§impl Clone for BookmarkStore
impl Clone for BookmarkStore
Source§fn clone(&self) -> BookmarkStore
fn clone(&self) -> BookmarkStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BookmarkStore
impl !RefUnwindSafe for BookmarkStore
impl Send for BookmarkStore
impl Sync for BookmarkStore
impl Unpin for BookmarkStore
impl UnsafeUnpin for BookmarkStore
impl !UnwindSafe for BookmarkStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more