Skip to main content

RecordStore

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

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

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>

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>

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>

Inspect durability without closing a typing transaction or scheduling work.

§Errors

Reports missing/reserved records.

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>

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

Share an existing set.

pub fn open(manifest_id: impl Into<String>) -> RecordStore

The production store: see RecordSet::open.

pub fn in_memory() -> RecordStore

A store that never touches disk: see RecordSet::in_memory.

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>

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>

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>

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>

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>

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>

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>

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>

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>

Inspect committed history without turning a pending burst into a boundary.

pub fn open_records(&self) -> Vec<RecordCheckout>

Every record this store holds.

pub fn tick(&self)

Offer every open record to its writer. Once per idle tick.

pub fn flush(&self)

Write out every open record and wait for it to land.

Trait Implementations§

§

impl Clone for RecordStore

§

fn clone(&self) -> RecordStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for RecordStore

§

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

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

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

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,