Struct RecordStore
pub struct RecordStore(/* private fields */);Expand description
A RecordSet several widgets share via a handle, so two tabs on the same file stay one
document; single-threaded on purpose, since a Mutex here would guard against nothing.
Implementations§
§impl RecordStore
impl RecordStore
pub fn with_history_or_why<R>(
&self,
id: &RecordId,
f: impl FnOnce(&mut AutoCommit, &mut UndoLog) -> R,
) -> Result<R, HistoryUnavailable>
pub fn with_history_or_why<R>( &self, id: &RecordId, f: impl FnOnce(&mut AutoCommit, &mut UndoLog) -> R, ) -> Result<R, HistoryUnavailable>
Self::with_history, saying why the record could not be changed
now: the store is in use, the record is lent to a frame or still
being created, or it is not open here.
§Errors
Why f did not run.
§impl RecordStore
impl RecordStore
pub fn route(
&self,
checkout: &RecordCheckout,
) -> Result<RouteSpec, RecordOpenError>
pub fn route( &self, checkout: &RecordCheckout, ) -> Result<RouteSpec, RecordOpenError>
Checked custody-to-wire mapping. Primary stays record=None on every host.
pub fn schedule_committed_history(&self, id: &RecordId) -> Result<(), String>
pub fn schedule_committed_history(&self, id: &RecordId) -> Result<(), String>
Schedule this already committed History result through its existing writer, without sweeping or closing other owners’ unfinished edits. # Errors The cache could not take the document, or the store is busy and took nothing.
pub fn content_revision(&self) -> String
pub fn content_revision(&self) -> String
Cheap content witness for retained projections over open records: base heads cover committed
changes, pending_ops the live typing transaction, and the record identity makes opening or
closing a document invalidate a snapshot.
pub fn package_and_home(&self) -> (String, String)
pub fn held_parts(&self, base: &RecordId) -> Vec<u64>
pub fn held_parts(&self, base: &RecordId) -> Vec<u64>
The numbers of the parts of the chain base this store holds, in order: those open here,
and those kept on this device unopened. Listing reads the store’s index, so a frame loop
asks on Self::kept_revision instead of every frame.
pub fn note_kept(&self)
pub fn note_kept(&self)
Tell the store that a record it does not have open was kept in its backend by someone else (a workspace’s replication, delivering a part another device started), so what follows the records it keeps looks again. Callable while a frame reads the store.
pub fn announce(&self, records: impl IntoIterator<Item = RecordId>)
pub fn announce(&self, records: impl IntoIterator<Item = RecordId>)
Peers wrote records of this store’s trees, which it does not hold: whatever follows those
trees takes them up at once, as after Self::note_kept. Callable while a frame reads the
store.
pub fn announced_parts(&self, base: &RecordId) -> Vec<u64>
pub fn announced_parts(&self, base: &RecordId) -> Vec<u64>
The numbers of the parts of the chain base peers wrote
(Self::announce), in order.
pub fn kept_revision(&self) -> u64
pub fn kept_revision(&self) -> u64
Moves whenever the store is told something arrived for what follows
it: Self::note_kept, Self::announce, Self::note_workspace_answered.
pub fn open_parts(&self, base: &RecordId) -> Vec<u64>
pub fn open_parts(&self, base: &RecordId) -> Vec<u64>
The numbers of the parts of the chain base open here and ready to read, in order. Reads no
index, so it is cheap enough for every frame.
pub fn window_records(&self, kind: &RecordKind) -> Vec<(RecordId, AutoCommit)>
pub fn window_records(&self, kind: &RecordKind) -> Vec<(RecordId, AutoCommit)>
Every window default record of kind this package keeps in this workspace, sorted by id, as
last made durable: what an app’s windows started, so a closed window’s document is reached
again. Read without taking a writer; a record that cannot be read, is retired or is not of
kind here is left out and logged.
pub fn try_open_record(
&self,
want: &RecordCheckout,
) -> Result<RecordOpenOutcome, RecordOpenError>
pub fn try_open_record( &self, want: &RecordCheckout, ) -> Result<RecordOpenOutcome, RecordOpenError>
Open Existing only; a missing document is never implicitly initialized. # Errors Reports ownership contention, absence, identity or schema refusal and storage failures.
pub fn reserve_record(
&self,
want: &RecordCheckout,
) -> Result<RecordReservation, RecordOpenError>
pub fn reserve_record( &self, want: &RecordCheckout, ) -> Result<RecordReservation, RecordOpenError>
Reserve a New identity with its gate and no document/history/writer yet: the workspace’s own records are reserved as shared writers, any other as its only writer.
§Errors
Refuses collisions, malformed existing data and unavailable storage.
pub fn is_ready(&self, id: &RecordId) -> bool
pub fn save_status(
&self,
id: &RecordId,
) -> Result<RecordSaveStatus, RecordOpenError>
pub fn save_status( &self, id: &RecordId, ) -> Result<RecordSaveStatus, RecordOpenError>
Inspect durability without closing a typing transaction or scheduling work.
§Errors
Reports missing/reserved records.
pub fn wake_on_save_progress(
&self,
id: &RecordId,
wake: Arc<dyn Fn() + Send + Sync>,
)
pub fn wake_on_save_progress( &self, id: &RecordId, wake: Arc<dyn Fn() + Send + Sync>, )
Have wake called whenever Self::save_status of id may change
without input: its store resolving its writer’s writes, or a host
acknowledging a portable cache. A memory-only record never changes.
Sample again once armed: a write that landed before is not heard of.
pub fn await_submitted(&self, id: &RecordId) -> Result<(), String>
pub fn await_submitted(&self, id: &RecordId) -> Result<(), String>
Block until the store has committed or refused every write id’s
writer already submitted, without submitting its pending edits: the
acknowledgement Self::save_status reports, awaited instead of
polled.
§Errors
Reports missing/busy records, an unpersisted record, and the writer’s outstanding failure.
pub fn durability_error(&self, id: &RecordId) -> Option<String>
pub fn try_flush(&self) -> Result<(), String>
pub fn try_flush(&self) -> Result<(), String>
Request current changes once and await actual acknowledgements for every record.
§Errors
Returns record-specific storage failures; a subsequent explicit retry sends a full checkpoint.
pub fn try_flush_written(&self) -> Result<(), String>
pub fn try_flush_written(&self) -> Result<(), String>
Write out what is not stored yet, and report only what failed: the
records are the store’s from then on, and the store’s own thread
commits them (RecordSet::try_flush_written).
pub fn new(set: RecordSet) -> RecordStore
pub fn new(set: RecordSet) -> RecordStore
Share an existing set.
pub fn open(manifest_id: impl Into<String>) -> RecordStore
pub fn open(manifest_id: impl Into<String>) -> RecordStore
The production store: see RecordSet::open.
pub fn in_memory() -> RecordStore
pub fn in_memory() -> RecordStore
A store that never touches disk: see RecordSet::in_memory.
pub fn open_record(&self, want: &RecordCheckout) -> bool
pub fn open_record(&self, want: &RecordCheckout) -> bool
Open want if it is not open already. Returns whether this opened
it.
pub fn create_record(
&self,
want: &RecordCheckout,
) -> Result<(), RecordOpenError>
pub fn create_record( &self, want: &RecordCheckout, ) -> Result<(), RecordOpenError>
Create exactly the new resource named by its owning action. Reopening existing tabs must use existing-only admission instead.
§Errors
Refuses existing identities, unavailable persistence, and invalid scope.
pub fn action_generation(
&self,
id: &RecordId,
) -> Result<Option<u64>, RecordOpenError>
pub fn action_generation( &self, id: &RecordId, ) -> Result<Option<u64>, RecordOpenError>
Generation of the record-owned action frame, for retained callers that need to invalidate a previously resolved operation.
§Errors
Returns Busy if the record set is borrowed, or MissingRecord if the record is not open.
pub fn merge_peer_document(
&self,
checkout: &RecordCheckout,
document: Vec<u8>,
) -> Result<bool, String>
pub fn merge_peer_document( &self, checkout: &RecordCheckout, document: Vec<u8>, ) -> Result<bool, String>
Merge a peer’s full document into an open record, exactly as a collaborator’s state arriving over sync is merged: validated first, and without moving the local author’s undo history onto the peer’s edits. Returns whether anything changed.
§Errors
Returns why the peer’s document was refused; the record is unchanged.
pub fn merge_peer_changes(
&self,
checkout: &RecordCheckout,
changes: Vec<u8>,
) -> Result<bool, String>
pub fn merge_peer_changes( &self, checkout: &RecordCheckout, changes: Vec<u8>, ) -> Result<bool, String>
Merge another replica’s incremental changes (what
Self::replication_delta answers there) into the open record, as
the workspace’s broker delivers one window’s changes to the others on the
record. Whether anything changed.
§Errors
The record is not open here or the changes do not merge.
pub fn withdraw_refused(
&self,
id: &RecordId,
refused: &[ChangeHash],
reason: &str,
) -> Result<Option<Vec<ChangeHash>>, String>
pub fn withdraw_refused( &self, id: &RecordId, refused: &[ChangeHash], reason: &str, ) -> Result<Option<Vec<ChangeHash>>, String>
Withdraw from the open record id the changes refused names, which
the workspace refused, with every local change made on top of them, and
note one RecordRefusal per action they carried, saying reason
(for a person), for the app to take (Self::take_refusals).
A refused change is shared state nowhere but here, and a peer holds
back every change that depends on one it never receives: kept, it
would show as sent forever and silence everything written after it.
The document becomes what it was without them, saved whole; local
undo starts over, since its steps may name withdrawn changes. A
replication frontier past them must be rebased onto the heads
this returns. Returns None when nothing was withdrawn: the record
holds none of them, or they are its creation (still noted).
§Errors
The record is not open here or its owner is busy, or the document does not rebuild.
pub fn hold_notice(
&self,
id: &RecordId,
text: String,
) -> Result<(), RecordOpenError>
pub fn hold_notice( &self, id: &RecordId, text: String, ) -> Result<(), RecordOpenError>
Say text of what was just done to the open record id once the
workspace it is shared in keeps it (WorkspaceNotices): at once when no
host replicates it, never when the workspace refuses it. The pending
action is committed first, so the change it names is among the heads
held.
§Errors
The record is not open here or its owner is busy.
pub fn workspace_settled(&self, id: &RecordId)
pub fn workspace_settled(&self, id: &RecordId)
The workspace’s host answered every commit of record id it published:
what was held for them is said (Self::take_said).
pub fn take_said(&self, id: &RecordId) -> Vec<String>
pub fn take_said(&self, id: &RecordId) -> Vec<String>
What to say now of record id (Self::hold_notice), each once.
pub fn take_refusals(&self, id: &RecordId) -> Vec<RecordRefusal>
pub fn take_refusals(&self, id: &RecordId) -> Vec<RecordRefusal>
The refusals of record id noted since the last call
(Self::withdraw_refused).
pub fn replication_delta(
&self,
id: &RecordId,
frontier: &mut DocumentFrontier,
) -> Result<(Vec<u8>, Vec<ChangeHash>), RecordOpenError>
pub fn replication_delta( &self, id: &RecordId, frontier: &mut DocumentFrontier, ) -> Result<(Vec<u8>, Vec<ChangeHash>), RecordOpenError>
Changes to the open record id that frontier has not covered, for a
host replicating open records itself (a browser page over the relay).
The record goes whole, another replica’s changes included; a route
publishes its own alone (Self::own_delta).
The pending action is committed first, as for a save. Advance the
frontier with the returned heads only once the delta was accepted.
§Errors
The record is not open here or its owner is busy.
pub fn own_delta(
&self,
id: &RecordId,
frontier: &mut DocumentFrontier,
) -> Result<(Vec<u8>, Vec<ChangeHash>), RecordOpenError>
pub fn own_delta( &self, id: &RecordId, frontier: &mut DocumentFrontier, ) -> Result<(Vec<u8>, Vec<ChangeHash>), RecordOpenError>
The changes to the open record id this replica made and frontier
has not published yet, for a route, which publishes its own device’s
changes and never another replica’s
(crate::state::DocumentFrontier::pending_delta). The pending action
is committed first, as for a save. Advance the frontier with the
returned heads only once the delta was accepted.
§Errors
The record is not open here or its owner is busy.
pub fn migrate<T>(
&self,
id: &RecordId,
migrate: impl FnOnce(&mut AutoCommit) -> Result<T, String>,
) -> Result<T, String>
pub fn migrate<T>( &self, id: &RecordId, migrate: impl FnOnce(&mut AutoCommit) -> Result<T, String>, ) -> Result<T, String>
Bring the open record id up with migrate, and note the actors it
wrote as among this replica’s own: a migration is one housekeeping
change whose actor is derived from the document rather than being this
device’s, so a route publishing this replica’s own changes
(crate::state::DocumentFrontier::pending_delta) sends it too.
§Errors
The record is not open here, its owner is busy, or migrate refused.
pub fn replication_snapshot(
&self,
id: &RecordId,
) -> Result<(Vec<u8>, Vec<ChangeHash>), RecordOpenError>
pub fn replication_snapshot( &self, id: &RecordId, ) -> Result<(Vec<u8>, Vec<ChangeHash>), RecordOpenError>
The open record id as a whole-document snapshot with its heads, for
a replica’s first publication.
§Errors
The record is not open here or its owner is busy.
pub fn merge_replica(
&self,
checkout: &RecordCheckout,
mutation: DocumentMutation,
) -> Result<(bool, Vec<ChangeHash>), String>
pub fn merge_replica( &self, checkout: &RecordCheckout, mutation: DocumentMutation, ) -> Result<(bool, Vec<ChangeHash>), String>
Merge a replica’s mutation into the open record, validating the
record’s identity on a private copy first; local undo stays local.
Returns whether the document changed and the change hashes the
mutation carried, for the replicating frontier’s observe.
§Errors
The bytes are not a valid mutation of this record, or it is not open.
pub fn with<R>(
&self,
id: &RecordId,
f: impl FnOnce(&mut AutoCommit) -> R,
) -> Option<R>
pub fn with<R>( &self, id: &RecordId, f: impl FnOnce(&mut AutoCommit) -> R, ) -> Option<R>
Do something with a record’s document. None if the record is not open here.
pub fn takes_writes(&self) -> bool
pub fn takes_writes(&self) -> bool
Whether the store takes a write now: not while something reads or changes it (a frame’s read of a record holds it).
pub fn read<R>( &self, id: &RecordId, f: impl FnOnce(&AutoCommit) -> R, ) -> Option<R>
pub fn with_history<R>(
&self,
id: &RecordId,
f: impl FnOnce(&mut AutoCommit, &mut UndoLog) -> R,
) -> Option<R>
pub fn with_history<R>( &self, id: &RecordId, f: impl FnOnce(&mut AutoCommit, &mut UndoLog) -> R, ) -> Option<R>
Do something with a record’s document and its history — commit an action, undo one.
pub fn read_history<R>(
&self,
id: &RecordId,
read: impl FnOnce(&AutoCommit, &UndoLog) -> R,
) -> Option<R>
pub fn read_history<R>( &self, id: &RecordId, read: impl FnOnce(&AutoCommit, &UndoLog) -> R, ) -> Option<R>
Inspect committed history without turning a pending burst into a boundary.
pub fn open_records(&self) -> Vec<RecordCheckout>
pub fn open_records(&self) -> Vec<RecordCheckout>
Every record this store holds.
pub fn open_tree_records(&self) -> Vec<RecordCheckout>
pub fn open_tree_records(&self) -> Vec<RecordCheckout>
The open records that belong to another’s tree (RecordId::tree),
ready to read; none while a frame holds the store.
§impl RecordStore
impl RecordStore
pub fn wake_on_arrival(&self, reader: WakeHandle)
pub fn wake_on_arrival(&self, reader: WakeHandle)
Wake the window reader belongs to whenever another replica’s change
arrives in this store: merged into an open record
(Self::merge_replica), or kept for a record it follows
(Self::note_kept, Self::announce). Nothing else tells a window
that its records moved, so without it what arrived waits for the
window’s next input or timer. A closed window’s handle is dropped.
pub fn note_workspace_answered(&self, id: RecordId)
pub fn note_workspace_answered(&self, id: RecordId)
The workspace’s hosts sent everything they hold of id, a record this
store asked them for (RecordId::arrives_on_demand), or no host is
connected to ask: what of it is here is all there is for now. What
reads it and still lacks it (a part held from its genesis that
nothing arrived in) shows it unavailable rather than loading, until
something of it arrives, which clears this. Wakes the store’s
readers. Callable while a frame reads the store.
pub fn workspace_answered(&self, id: &RecordId) -> bool
pub fn workspace_answered(&self, id: &RecordId) -> bool
Whether the workspace’s hosts sent everything they hold of id
(Self::note_workspace_answered) and nothing of it arrived since.
§impl RecordStore
impl RecordStore
pub fn begin_opening(
&self,
want: &RecordCheckout,
) -> Result<bool, RecordOpenError>
pub fn begin_opening( &self, want: &RecordCheckout, ) -> Result<bool, RecordOpenError>
Begin opening the record want off the frame, when it is the workspace’s own document and
this device holds it: its bytes are read now and decoded on a thread of their own. Until
it is taken in it is not open, and the window that opened it
shows what it can without it. Whether it began; a record that is not here, or is opened
another way, opens as before.
§Errors
The record’s owner or bytes cannot be had.
pub fn home(&self) -> String
pub fn home(&self) -> String
The workspace these records are kept in: what a window keys what it keeps on this device by the workspace, before any record of it is read.
pub fn is_opening(&self, id: &RecordId) -> bool
pub fn is_opening(&self, id: &RecordId) -> bool
Whether the record id is being opened off the frame and is not taken in yet.
pub fn opening(&self, want: &RecordCheckout) -> RecordOpening
pub fn opening(&self, want: &RecordCheckout) -> RecordOpening
The record want as it opens off the frame.
Trait Implementations§
§impl Clone for RecordStore
impl Clone for RecordStore
§fn clone(&self) -> RecordStore
fn clone(&self) -> RecordStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RecordStore
impl !RefUnwindSafe for RecordStore
impl !Send for RecordStore
impl !Sync for RecordStore
impl Unpin for RecordStore
impl UnsafeUnpin for RecordStore
impl !UnwindSafe for RecordStore
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> 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>, which can then be
downcast into Box<dyn 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>, which 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> 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