pub struct Tag { /* private fields */ }Expand description
A tag from Bear’s database.
Tags in Bear organize notes hierarchically (e.g., “work/projects/bear-query”).
§Nullable Fields
name: Tag name. In theory should never be NULL, but we handle it defensively. A tag without a name would be unusual but possible in a corrupted database.modified: Timestamp of last modification. May beNonefor tags that have never been explicitly modified.
§Example
let db = BearDb::new()?;
let tags = db.tags()?;
for tag in tags.iter() {
let name = tag.name().unwrap_or("[unnamed]");
match tag.modified() {
Some(modified) => println!("Tag '{}' modified: {}", name, modified),
None => println!("Tag '{}' (never modified)", name),
}
}Implementations§
Source§impl Tag
impl Tag
Sourcepub fn id(&self) -> TagId
pub fn id(&self) -> TagId
Returns the tag’s primary key identifier.
This is always present (never NULL) and stable across the tag’s lifetime.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns the tag’s name, if present.
Returns None in the rare case of a tag without a name (corrupted data).
Tag names can be hierarchical, using / as separator:
"work"- top-level tag"work/projects"- nested tag"work/projects/bear-query"- deeply nested tag
Sourcepub fn modified(&self) -> Option<OffsetDateTime>
pub fn modified(&self) -> Option<OffsetDateTime>
Returns the timestamp of the tag’s last modification, if available.
Returns None for tags that have never been explicitly modified.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tag
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnwindSafe for Tag
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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