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 rather than drifting under per-widget
ownership. Single-threaded on purpose — a widget tree is, and a
Mutex here would guard against nothing.
Implementations§
§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 content_revision(&self) -> String
pub fn content_revision(&self) -> String
Cheap content witness for retained projections over open records.
Base heads cover committed changes and pending_ops covers the live
typing transaction before its next commit boundary. Record identity is
included so opening or closing a document also invalidates a snapshot.
pub fn package_and_home(&self) -> (String, String)
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/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 exclusive gate and no document/history/writer yet.
§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 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 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 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 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 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 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 tick(&self)
pub fn tick(&self)
Offer every open record to its writer. Once per idle tick.
pub fn flush(&self)
pub fn flush(&self)
Write out every open record and wait for it to land.
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> 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