pub struct NotesStore { /* private fields */ }Expand description
The file, open, with the CRDTs it has loaded and who is on them.
Implementations§
Source§impl NotesStore
impl NotesStore
Sourcepub fn open(path: &Path) -> Result<Self, StoreError>
pub fn open(path: &Path) -> Result<Self, StoreError>
The store on path, made if missing; a file without the tables
gains them, empty — once; on every later open a no-op. Every write
allowed (crate::quota::AllowAll) until a meter is set.
Sourcepub fn metered(self, quota: Arc<dyn Quota>) -> Self
pub fn metered(self, quota: Arc<dyn Quota>) -> Self
The same store, its writes reserved against quota (V2-31’s meter).
Sourcepub fn set_quota(&self, quota: Arc<dyn Quota>)
pub fn set_quota(&self, quota: Arc<dyn Quota>)
V2-31: its writes reserved against quota from now on — the builder
sets the quota service’s meter on a store already shared.
Sourcepub async fn usage_by_principal(
self: &Arc<Self>,
) -> Result<Vec<(String, u64, u64)>, StoreError>
pub async fn usage_by_principal( self: &Arc<Self>, ) -> Result<Vec<(String, u64, u64)>, StoreError>
V2-31: what each principal keeps, as the quota service counts it —
the update log as stored: every change’s bytes its writer’s, and
a squash’s snapshot shared among its authors by what each wrote
(crate::events::shares) — so a squash shrinks it; count the
notes they made (a create change, or, folded into a snapshot,
its earliest author’s). (principal, count, bytes), by principal.
Sourcepub async fn usage_daily(
self: &Arc<Self>,
) -> Result<Vec<(String, i64, u64, u64)>, StoreError>
pub async fn usage_daily( self: &Arc<Self>, ) -> Result<Vec<(String, i64, u64, u64)>, StoreError>
V2-70: Self::usage_by_principal by the UTC day each change was
kept (days since 1970-01-01; a snapshot’s shares on its own day):
(principal, day, count, bytes) — what the quota service’s history is
backfilled from; summed per principal, the same.
Sourcepub async fn get(self: &Arc<Self>, id: &str) -> Result<Note, StoreError>
pub async fn get(self: &Arc<Self>, id: &str) -> Result<Note, StoreError>
The note id as it is now, body and all; StoreError::NotFound
for none (or a deleted one).
Sourcepub async fn list(self: &Arc<Self>, ask: Listing) -> Result<Page, StoreError>
pub async fn list(self: &Arc<Self>, ask: Listing) -> Result<Page, StoreError>
A page of the notes ask admits, newest made first, without
their bodies.
Sourcepub async fn rename(
self: &Arc<Self>,
id: &str,
title: &str,
by: &str,
principal: &str,
) -> Result<Note, StoreError>
pub async fn rename( self: &Arc<Self>, id: &str, title: &str, by: &str, principal: &str, ) -> Result<Note, StoreError>
Retitles id to title, by by (principal): a change more in the log.
Sourcepub async fn delete(
self: &Arc<Self>,
id: &str,
by: &str,
principal: &str,
) -> Result<(String, i64), StoreError>
pub async fn delete( self: &Arc<Self>, id: &str, by: &str, principal: &str, ) -> Result<(String, i64), StoreError>
Deletes id, by by: it reads as none from now on; its log, and one
row more saying the delete, stay in the file.
Source§impl NotesStore
impl NotesStore
Sourcepub async fn create(
self: &Arc<Self>,
org: &str,
title: &str,
body: &str,
by: &str,
principal: &str,
) -> Result<Note, StoreError>
pub async fn create( self: &Arc<Self>, org: &str, title: &str, body: &str, by: &str, principal: &str, ) -> Result<Note, StoreError>
Makes a note in org, titled title, its body body, by by
(principal): change 1, its id fresh (crate::vocab::mint).
Sourcepub async fn update(
self: &Arc<Self>,
id: &str,
update: &str,
by: &str,
principal: &str,
session: Option<String>,
) -> Result<Written, StoreError>
pub async fn update( self: &Arc<Self>, id: &str, update: &str, by: &str, principal: &str, session: Option<String>, ) -> Result<Written, StoreError>
notes.update: a writer’s Yjs v1 update (update, base64) applied to
id’s CRDT and kept, by by (principal), from the presence
session when it says.
Sourcepub async fn save(
self: &Arc<Self>,
id: &str,
body: &str,
base: Option<u32>,
by: &str,
principal: &str,
) -> Result<Written, StoreError>
pub async fn save( self: &Arc<Self>, id: &str, body: &str, base: Option<u32>, by: &str, principal: &str, ) -> Result<Written, StoreError>
notes.save: body whole, by by — made into the CRDT’s own edits by
a diff of the text its writer read (base, the revision it read)
against body, made on the CRDT as it stood then and merged into it
now: what others wrote since stays. With no base (or one squashed
away) the diff is against the text now. A body equal to the text
writes nothing.
Sourcepub async fn state(
self: &Arc<Self>,
id: &str,
vector: Option<String>,
) -> Result<Synced, StoreError>
pub async fn state( self: &Arc<Self>, id: &str, vector: Option<String>, ) -> Result<Synced, StoreError>
notes.state: what a client whose state vector is vector (base64;
none: it holds nothing) lacks of id, and the note’s own vector.
Sourcepub async fn replay(
self: &Arc<Self>,
id: &str,
seq: Option<u32>,
at: Option<i64>,
) -> Result<Note, StoreError>
pub async fn replay( self: &Arc<Self>, id: &str, seq: Option<u32>, at: Option<i64>, ) -> Result<Note, StoreError>
notes.replay: id as it stood after change seq — or, with at
(unix milliseconds), after the last change made by then: the log to
there applied to a fresh CRDT, the title as it was. A moment before
the first change kept (or before a squash’s snapshot) is
StoreError::NoRevision.
Sourcepub async fn restore(
self: &Arc<Self>,
id: &str,
seq: u32,
by: &str,
principal: &str,
) -> Result<Written, StoreError>
pub async fn restore( self: &Arc<Self>, id: &str, seq: u32, by: &str, principal: &str, ) -> Result<Written, StoreError>
notes.restore: id’s body put back as it stood after change seq,
by by — a whole-body write over the CRDT (NotesStore::save), so a
restore is a change like any other, merged with live typing.
Sourcepub async fn history(
self: &Arc<Self>,
id: &str,
limit: usize,
before: Option<u32>,
) -> Result<Vec<HistoryRow>, StoreError>
pub async fn history( self: &Arc<Self>, id: &str, limit: usize, before: Option<u32>, ) -> Result<Vec<HistoryRow>, StoreError>
notes.history: id’s changes, newest first, at most limit, those
before before (a seq) when it says.
Sourcepub async fn squash(
self: &Arc<Self>,
id: &str,
until: u32,
by: &str,
principal: &str,
) -> Result<u32, StoreError>
pub async fn squash( self: &Arc<Self>, id: &str, until: u32, by: &str, principal: &str, ) -> Result<u32, StoreError>
notes.squash: id’s changes up to until (a seq) collapsed into
one snapshot row at until — the CRDT as it stood then — its
authors saying who wrote what in them (an earlier snapshot’s authors
folded in). Answers how many rows went. Nothing after until moves.
Source§impl NotesStore
impl NotesStore
Sourcepub fn arrive(
&self,
id: &str,
org: &str,
session: &str,
who: &Who,
held: bool,
client: Option<u64>,
awareness: Option<String>,
) -> Present
pub fn arrive( &self, id: &str, org: &str, session: &str, who: &Who, held: bool, client: Option<u64>, awareness: Option<String>, ) -> Present
who is on id (in org) as session — held by a watch when
held, else until it idles out; its caret as client and
awareness say, when they do. Said as present to everyone on it.
Sourcepub fn taken(&self, id: &str, session: &str, principal: &str) -> bool
pub fn taken(&self, id: &str, session: &str, principal: &str) -> bool
Whether session on id is someone else’s than principal.
Source§impl NotesStore
impl NotesStore
Sourcepub async fn ask(
self: &Arc<Self>,
id: &str,
from: u32,
to: u32,
question: &str,
to_whom: Option<String>,
hand: Hand,
) -> Result<Thread, StoreError>
pub async fn ask( self: &Arc<Self>, id: &str, from: u32, to: u32, question: &str, to_whom: Option<String>, hand: Hand, ) -> Result<Thread, StoreError>
notes.ask: a question on the characters from..to of id’s text
now, anchored in its CRDT, to to_whom when it says, by hand.
Sourcepub async fn reply(
self: &Arc<Self>,
id: &str,
thread: &str,
body: &str,
hand: Hand,
) -> Result<Thread, StoreError>
pub async fn reply( self: &Arc<Self>, id: &str, thread: &str, body: &str, hand: Hand, ) -> Result<Thread, StoreError>
notes.reply: body under the thread, by hand.
Sourcepub async fn resolve(
self: &Arc<Self>,
id: &str,
thread: &str,
open: bool,
hand: Hand,
) -> Result<Thread, StoreError>
pub async fn resolve( self: &Arc<Self>, id: &str, thread: &str, open: bool, hand: Hand, ) -> Result<Thread, StoreError>
notes.resolve: the thread folded, by hand (again: it opens).
Source§impl NotesStore
impl NotesStore
Sourcepub async fn slot(self: &Arc<Self>, id: &str) -> Result<Slot, StoreError>
pub async fn slot(self: &Arc<Self>, id: &str) -> Result<Slot, StoreError>
The slot of the live note id, with every fill and the build under way.
Sourcepub async fn fill(
self: &Arc<Self>,
id: &str,
fill: FillOf,
hand: Hand,
) -> Result<Slot, StoreError>
pub async fn fill( self: &Arc<Self>, id: &str, fill: FillOf, hand: Hand, ) -> Result<Slot, StoreError>
Fills the slot of id with fill — a fill more, the build under way
ended — and says it.
Sourcepub async fn empty(
self: &Arc<Self>,
id: &str,
hand: Hand,
) -> Result<Slot, StoreError>
pub async fn empty( self: &Arc<Self>, id: &str, hand: Hand, ) -> Result<Slot, StoreError>
Empties the slot of id — nothing drawn, its props cleared, its
fills kept, the build under way ended — and says it.
Sourcepub async fn props(
self: &Arc<Self>,
id: &str,
patch: Map<String, Value>,
hand: Hand,
) -> Result<Slot, StoreError>
pub async fn props( self: &Arc<Self>, id: &str, patch: Map<String, Value>, hand: Hand, ) -> Result<Slot, StoreError>
Merges patch into the props of id’s slot (a null takes its key
away), held to crate::vocab::PROPS_MAX, and says it.
Sourcepub async fn building(
self: &Arc<Self>,
id: &str,
building: Building,
) -> Result<Slot, StoreError>
pub async fn building( self: &Arc<Self>, id: &str, building: Building, ) -> Result<Slot, StoreError>
Marks id’s slot as being built — building its word now (kept from
the build before when it is of the same component and has not
failed) — and says it.
Sourcepub fn sweep_builds(&self)
pub fn sweep_builds(&self)
Ends every build silent for BUILD_IDLE_MS, saying each.
Source§impl NotesStore
impl NotesStore
Sourcepub async fn mark(
self: &Arc<Self>,
id: &str,
from: u32,
to: u32,
of: Remark,
hand: Hand,
) -> Result<Mark, StoreError>
pub async fn mark( self: &Arc<Self>, id: &str, from: u32, to: u32, of: Remark, hand: Hand, ) -> Result<Mark, StoreError>
notes.mark: a mark on the characters from..to of id’s text now,
anchored in its CRDT (which it does not change), with its link and
label (empty: none), by hand.
Sourcepub async fn remark(
self: &Arc<Self>,
id: &str,
mark: &str,
to: Remark,
hand: Hand,
) -> Result<Mark, StoreError>
pub async fn remark( self: &Arc<Self>, id: &str, mark: &str, to: Remark, hand: Hand, ) -> Result<Mark, StoreError>
notes.mark { mark }: the mark mark of id changed as to says, by hand.
Sourcepub async fn mark_props(
self: &Arc<Self>,
id: &str,
mark: &str,
patch: Map<String, Value>,
hand: Hand,
) -> Result<Mark, StoreError>
pub async fn mark_props( self: &Arc<Self>, id: &str, mark: &str, patch: Map<String, Value>, hand: Hand, ) -> Result<Mark, StoreError>
notes.mark_props: patch merged into the props of the mark mark
of id (a null takes its key away), held to 64 KiB, by hand.