pub struct SqliteAnnotationRepository { /* private fields */ }Implementations§
Source§impl SqliteAnnotationRepository
impl SqliteAnnotationRepository
pub fn new(db: Database) -> Self
Sourcepub fn create(&self, annotation: &Annotation) -> Result<(), DbError>
pub fn create(&self, annotation: &Annotation) -> Result<(), DbError>
Insert a new annotation. Caller is responsible for building the
Annotation (see Annotation::new_root / new_reply).
Sourcepub fn create_in_tx(
tx: &Transaction<'_>,
annotation: &Annotation,
) -> Result<(), DbError>
pub fn create_in_tx( tx: &Transaction<'_>, annotation: &Annotation, ) -> Result<(), DbError>
Transactional sibling of Self::create (#157). Used by the
bib-import orchestrator so paper-save + alias-record + annotation-
create commit (or roll back) as a single unit per row.
Sourcepub fn get(&self, id: &str) -> Result<Option<Annotation>, DbError>
pub fn get(&self, id: &str) -> Result<Option<Annotation>, DbError>
Fetch an annotation by ID (live rows only).
Sourcepub fn list_by_paper(&self, paper_id: &str) -> Result<Vec<Annotation>, DbError>
pub fn list_by_paper(&self, paper_id: &str) -> Result<Vec<Annotation>, DbError>
All live annotations anchored to a paper (roots + replies).
Sourcepub fn list_replies(&self, parent_id: &str) -> Result<Vec<Annotation>, DbError>
pub fn list_replies(&self, parent_id: &str) -> Result<Vec<Annotation>, DbError>
All live replies to a specific root annotation, ordered oldest-first.
Sourcepub fn update_note(
&self,
id: &str,
note: &str,
color: Option<&str>,
tags: &[String],
) -> Result<(), DbError>
pub fn update_note( &self, id: &str, note: &str, color: Option<&str>, tags: &[String], ) -> Result<(), DbError>
Update mutable fields (note / color / tags). Anchor is updated
separately via update_anchor since it has its own lifecycle.
Sourcepub fn update_anchor(&self, id: &str, anchor: &Anchor) -> Result<(), DbError>
pub fn update_anchor(&self, id: &str, anchor: &Anchor) -> Result<(), DbError>
Persist the resolver’s updated anchor state. Called after
resolve_anchor runs on paper-open.
Sourcepub fn soft_delete(&self, id: &str) -> Result<(), DbError>
pub fn soft_delete(&self, id: &str) -> Result<(), DbError>
Soft-delete — tombstones the row so replies still point at
something, and list_* queries skip it.
Sourcepub fn mark_seen(
&self,
annotation_ids: &[&str],
reader: &str,
) -> Result<(), DbError>
pub fn mark_seen( &self, annotation_ids: &[&str], reader: &str, ) -> Result<(), DbError>
Record that reader has seen the current state of each annotation.
Upserts so repeat calls bump seen_at.
Sourcepub fn mark_thread_seen(
&self,
root_id: &str,
reader: &str,
) -> Result<(), DbError>
pub fn mark_thread_seen( &self, root_id: &str, reader: &str, ) -> Result<(), DbError>
Mark the thread rooted at root_id (root + all live replies) as
seen by reader.
Sourcepub fn list_unread(
&self,
reader: &str,
paper_id: Option<&str>,
) -> Result<Vec<Annotation>, DbError>
pub fn list_unread( &self, reader: &str, paper_id: Option<&str>, ) -> Result<Vec<Annotation>, DbError>
Annotations the reader hasn’t seen since the last modification.
Optional paper_id scopes the query. Uses a LEFT JOIN so rows
with no receipt count as unread; rows whose seen_at is older
than updated_at also count (the annotation changed since last
view).
Sourcepub fn papers_with_unread(
&self,
reader: &str,
) -> Result<HashSet<String>, DbError>
pub fn papers_with_unread( &self, reader: &str, ) -> Result<HashSet<String>, DbError>
Set of paper IDs that have at least one annotation reader
hasn’t acknowledged. Drives the per-row ● glyph on the
Papers list — one indexed query per draw tick. (#185)
Sourcepub fn count_unread(
&self,
reader: &str,
paper_id: Option<&str>,
) -> Result<i64, DbError>
pub fn count_unread( &self, reader: &str, paper_id: Option<&str>, ) -> Result<i64, DbError>
Same predicate as list_unread but returns just the count.
Called on every TUI draw tick (~10 Hz) to drive the status-bar
[N new] badge — COUNT(*) keeps the per-tick cost in
microseconds even when there are many annotations. (#185)
Trait Implementations§
Source§impl Clone for SqliteAnnotationRepository
impl Clone for SqliteAnnotationRepository
Source§fn clone(&self) -> SqliteAnnotationRepository
fn clone(&self) -> SqliteAnnotationRepository
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more