Skip to main content

NotesStore

Struct NotesStore 

Source
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

Source

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.

Source

pub fn metered(self, quota: Arc<dyn Quota>) -> Self

The same store, its writes reserved against quota (V2-31’s meter).

Source

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.

Source

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.

Source

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.

Source

pub fn path(&self) -> &Path

The file it keeps.

Source

pub fn subscribe(&self) -> Receiver<Change>

Every write from now on, as it is committed.

Source

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).

Source

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.

Source

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.

Source

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

pub async fn org_of(self: &Arc<Self>, id: &str) -> Result<String, StoreError>

The organization the live note id is in.

Source

pub fn count(&self) -> usize

How many notes the store keeps — for a log line.

Source§

impl NotesStore

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

pub fn taken(&self, id: &str, session: &str, principal: &str) -> bool

Whether session on id is someone else’s than principal.

Source

pub fn leave(&self, id: &str, session: &str)

A watch holding session on id ended: the entry goes when no other watch holds it. Said as left.

Source

pub fn present(&self, id: &str) -> Vec<Present>

Everyone on id now.

Source

pub fn sweep(&self)

The entries idle past their time, gone — each said as left.

Source§

impl NotesStore

Source

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.

Source

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.

Source

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

pub async fn threads( self: &Arc<Self>, id: &str, ) -> Result<Vec<Thread>, StoreError>

notes.threads: id’s threads, by where they stand in the text — the detached ones at the end, each by when it was asked.

Source

pub async fn waiting( self: &Arc<Self>, orgs: Vec<String>, to: Option<String>, ) -> Result<Vec<Thread>, StoreError>

notes.waiting: the open threads asked of someone (to_whom) in the notes of orgs, oldest first — to keeping those asked of it.

Source§

impl NotesStore

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn sweep_builds(&self)

Ends every build silent for BUILD_IDLE_MS, saying each.

Source§

impl NotesStore

Source

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.

Source

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.

Source

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.

Source

pub async fn unmark( self: &Arc<Self>, id: &str, mark: &str, ) -> Result<(), StoreError>

notes.unmark: the mark mark taken off id.

Source

pub async fn marks(self: &Arc<Self>, id: &str) -> Result<Vec<Mark>, StoreError>

notes.marks: id’s marks, by where they stand in the text — the detached ones at the end, each by when it was made.

Trait Implementations§

Source§

impl Debug for NotesStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more