Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

ReadTxn

Trait ReadTxn 

pub trait ReadTxn: Sized {
Show 21 methods // Required method fn store(&self) -> &Store; // Provided methods fn state_vector(&self) -> StateVector { ... } fn snapshot(&self) -> Snapshot { ... } fn encode_state_from_snapshot<E>( &self, snapshot: &Snapshot, encoder: &mut E, ) -> Result<(), Error> where E: Encoder { ... } fn encode_diff<E>(&self, state_vector: &StateVector, encoder: &mut E) where E: Encoder { ... } fn encode_diff_v1(&self, state_vector: &StateVector) -> Vec<u8> { ... } fn encode_diff_v2(&self, state_vector: &StateVector) -> Vec<u8> { ... } fn encode_state_as_update<E>(&self, sv: &StateVector, encoder: &mut E) where E: Encoder { ... } fn encode_state_as_update_v1(&self, sv: &StateVector) -> Vec<u8> { ... } fn encode_state_as_update_v2(&self, sv: &StateVector) -> Vec<u8> { ... } fn root_refs(&self) -> RootRefs<'_> { ... } fn subdoc_guids(&self) -> SubdocGuids<'_> { ... } fn subdocs(&self) -> SubdocsIter<'_> { ... } fn get_text<N>(&self, name: N) -> Option<TextRef> where N: Into<Arc<str>> { ... } fn get_array<N>(&self, name: N) -> Option<ArrayRef> where N: Into<Arc<str>> { ... } fn get_map<N>(&self, name: N) -> Option<MapRef> where N: Into<Arc<str>> { ... } fn get_xml_fragment<N>(&self, name: N) -> Option<XmlFragmentRef> where N: Into<Arc<str>> { ... } fn get<S>(&self, name: S) -> Option<Out> where S: AsRef<str> { ... } fn parent_doc(&self) -> Option<Doc> { ... } fn branch_id(&self) -> Option<BranchID> { ... } fn has_missing_updates(&self) -> bool { ... }
}
Expand description

Trait defining read capabilities present in a transaction. Implemented by both lightweight read-only and read-write transactions.

Required Methods§

fn store(&self) -> &Store

Provided Methods§

fn state_vector(&self) -> StateVector

Returns state vector describing current state of the updates.

fn snapshot(&self) -> Snapshot

Returns a snapshot which describes a current state of updates and removals made within the corresponding document.

fn encode_state_from_snapshot<E>( &self, snapshot: &Snapshot, encoder: &mut E, ) -> Result<(), Error>
where E: Encoder,

Encodes all changes from current transaction block store up to a given snapshot. This enables to encode state of a document at some specific point in the past.

fn encode_diff<E>(&self, state_vector: &StateVector, encoder: &mut E)
where E: Encoder,

Encodes the difference between remote peer state given its state_vector and the state of a current local peer.

§Differences between alternative methods
  • Self::encode_state_as_update encodes full document state including pending updates and entire delete set.
  • Self::encode_diff encodes only the difference between the current state and the given state vector, including entire delete set. Pending updates are not included.
  • TransactionMut::encode_update encodes only inserts and deletes made within the scope of the current transaction.

fn encode_diff_v1(&self, state_vector: &StateVector) -> Vec<u8>

Encodes the difference between remote peer state given its state_vector and the state of a current local peer, using lib0 v1 encoding.

§Differences between alternative methods

fn encode_diff_v2(&self, state_vector: &StateVector) -> Vec<u8>

Encodes the difference between remote peer state given its state_vector and the state of a current local peer, using lib0 v2 encoding.

§Differences between alternative methods

fn encode_state_as_update<E>(&self, sv: &StateVector, encoder: &mut E)
where E: Encoder,

Encodes the difference between remote peer state given its state_vector and the state of a current local peer. Also includes pending updates which were not yet integrated into the main document state and entire delete set.

§Differences between alternative methods
  • Self::encode_state_as_update encodes full document state including pending updates and entire delete set.
  • Self::encode_diff encodes only the difference between the current state and the given state vector, including entire delete set. Pending updates are not included.
  • TransactionMut::encode_update encodes only inserts and deletes made within the scope of the current transaction.

fn encode_state_as_update_v1(&self, sv: &StateVector) -> Vec<u8>

Encodes the difference between remote peer state given its state_vector and the state of a current local peer, using lib0 v1 encoding. Also includes pending updates which were not yet integrated into the main document state and entire delete set.

§Differences between alternative methods

fn encode_state_as_update_v2(&self, sv: &StateVector) -> Vec<u8>

Encodes the difference between remote peer state given its state_vector and the state of a current local peer, using lib0 v2 encoding. Also includes pending updates which were not yet integrated into the main document state and entire delete set.

§Differences between alternative methods

fn root_refs(&self) -> RootRefs<'_>

Returns an iterator over top level (root) shared types available in current Doc.

fn subdoc_guids(&self) -> SubdocGuids<'_>

Returns a collection of globally unique identifiers of sub documents linked within the structures of this document store.

fn subdocs(&self) -> SubdocsIter<'_>

Returns a collection of sub documents linked within the structures of this document store.

fn get_text<N>(&self, name: N) -> Option<TextRef>
where N: Into<Arc<str>>,

Returns a TextRef data structure stored under a given name. Text structures are used for collaborative text editing: they expose operations to append and remove chunks of text, which are free to execute concurrently by multiple peers over remote boundaries.

If not structure under defined name existed before, None will be returned.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a text (in such case a sequence component of complex data type will be interpreted as a list of text chunks).

fn get_array<N>(&self, name: N) -> Option<ArrayRef>
where N: Into<Arc<str>>,

Returns an ArrayRef data structure stored under a given name. Array structures are used for storing a sequences of elements in ordered manner, positioning given element accordingly to its index.

If not structure under defined name existed before, None will be returned.

If a structure under defined name already existed, but its type was different it will be reinterpreted as an array (in such case a sequence component of complex data type will be interpreted as a list of inserted values).

fn get_map<N>(&self, name: N) -> Option<MapRef>
where N: Into<Arc<str>>,

Returns a MapRef data structure stored under a given name. Maps are used to store key-value pairs associated. These values can be primitive data (similar but not limited to a JavaScript Object Notation) as well as other shared types (Yrs maps, arrays, text structures etc.), enabling to construct a complex recursive tree structures.

If not structure under defined name existed before, None will be returned.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a map (in such case a map component of complex data type will be interpreted as native map).

fn get_xml_fragment<N>(&self, name: N) -> Option<XmlFragmentRef>
where N: Into<Arc<str>>,

Returns a XmlFragmentRef data structure stored under a given name. XML elements represent nodes of XML document. They can contain attributes (key-value pairs, both of string type) and other nested XML elements or text values, which are stored in their insertion order.

If not structure under defined name existed before, None will be returned.

If a structure under defined name already existed, but its type was different it will be reinterpreted as a XML element (in such case a map component of complex data type will be interpreted as map of its attributes, while a sequence component - as a list of its child XML nodes).

fn get<S>(&self, name: S) -> Option<Out>
where S: AsRef<str>,

fn parent_doc(&self) -> Option<Doc>

If current document has been inserted as a sub-document, returns a reference to a parent document, which contains it.

fn branch_id(&self) -> Option<BranchID>

If current document has been inserted as a sub-document, returns its BranchID.

fn has_missing_updates(&self) -> bool

Returns true if current document has any pending updates that are not yet integrated into the document.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<'doc> ReadTxn for Transaction<'doc>

§

impl<'doc> ReadTxn for TransactionMut<'doc>