pub trait ReadTxn: Sized {
Show 20 methods
// Required method
fn store(&self) -> &Store;
// Provided methods
fn state_vector(&self) -> StateVector { ... }
fn snapshot(&self) -> Snapshot { ... }
fn encode_state_from_snapshot<E: Encoder>(
&self,
snapshot: &Snapshot,
encoder: &mut E,
) -> Result<(), Error> { ... }
fn encode_diff<E: Encoder>(
&self,
state_vector: &StateVector,
encoder: &mut E,
) { ... }
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: Encoder>(
&self,
sv: &StateVector,
encoder: &mut E,
) { ... }
fn encode_state_as_update_v1(&self, sv: &StateVector) -> Vec<u8> ⓘ { ... }
fn encode_state_as_update_v2(&self, sv: &StateVector) -> Vec<u8> ⓘ { ... }
fn is_alive<B>(&self, node: &B) -> bool
where B: SharedRef { ... }
fn root_refs(&self) -> RootRefs<'_> ⓘ { ... }
fn subdoc_guids(&self) -> SubdocGuids<'_> { ... }
fn subdocs(&self) -> SubdocsIter<'_> { ... }
fn get_text<N: Into<Arc<str>>>(&self, name: N) -> Option<TextRef> { ... }
fn get_array<N: Into<Arc<str>>>(&self, name: N) -> Option<ArrayRef> { ... }
fn get_map<N: Into<Arc<str>>>(&self, name: N) -> Option<MapRef> { ... }
fn get_xml_fragment<N: Into<Arc<str>>>(
&self,
name: N,
) -> Option<XmlFragmentRef> { ... }
fn parent_doc(&self) -> Option<Doc> { ... }
fn branch_id(&self) -> Option<BranchID> { ... }
}
Expand description
Trait defining read capabilities present in a transaction. Implemented by both lightweight read-only and read-write transactions.
Required Methods§
Provided Methods§
sourcefn state_vector(&self) -> StateVector
fn state_vector(&self) -> StateVector
Returns state vector describing current state of the updates.
sourcefn snapshot(&self) -> Snapshot
fn snapshot(&self) -> Snapshot
Returns a snapshot which describes a current state of updates and removals made within the corresponding document.
sourcefn encode_state_from_snapshot<E: Encoder>(
&self,
snapshot: &Snapshot,
encoder: &mut E,
) -> Result<(), Error>
fn encode_state_from_snapshot<E: Encoder>( &self, snapshot: &Snapshot, encoder: &mut E, ) -> Result<(), Error>
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.
sourcefn encode_diff<E: Encoder>(&self, state_vector: &StateVector, encoder: &mut E)
fn encode_diff<E: Encoder>(&self, state_vector: &StateVector, encoder: &mut E)
Encodes the difference between remove peer state given its state_vector
and the state
of a current local peer
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: Encoder>(&self, sv: &StateVector, encoder: &mut E)
fn encode_state_as_update_v1(&self, sv: &StateVector) -> Vec<u8> ⓘ
fn encode_state_as_update_v2(&self, sv: &StateVector) -> Vec<u8> ⓘ
sourcefn is_alive<B>(&self, node: &B) -> boolwhere
B: SharedRef,
fn is_alive<B>(&self, node: &B) -> boolwhere
B: SharedRef,
Check if given node is alive. Returns false if node has been deleted.
sourcefn root_refs(&self) -> RootRefs<'_> ⓘ
fn root_refs(&self) -> RootRefs<'_> ⓘ
Returns an iterator over top level (root) shared types available in current Doc.
sourcefn subdoc_guids(&self) -> SubdocGuids<'_>
fn subdoc_guids(&self) -> SubdocGuids<'_>
Returns a collection of globally unique identifiers of sub documents linked within the structures of this document store.
sourcefn subdocs(&self) -> SubdocsIter<'_>
fn subdocs(&self) -> SubdocsIter<'_>
Returns a collection of sub documents linked within the structures of this document store.
sourcefn get_text<N: Into<Arc<str>>>(&self, name: N) -> Option<TextRef>
fn get_text<N: Into<Arc<str>>>(&self, name: N) -> Option<TextRef>
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).
sourcefn get_array<N: Into<Arc<str>>>(&self, name: N) -> Option<ArrayRef>
fn get_array<N: Into<Arc<str>>>(&self, name: N) -> Option<ArrayRef>
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).
sourcefn get_map<N: Into<Arc<str>>>(&self, name: N) -> Option<MapRef>
fn get_map<N: Into<Arc<str>>>(&self, name: N) -> Option<MapRef>
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).
sourcefn get_xml_fragment<N: Into<Arc<str>>>(&self, name: N) -> Option<XmlFragmentRef>
fn get_xml_fragment<N: Into<Arc<str>>>(&self, name: N) -> Option<XmlFragmentRef>
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).
sourcefn parent_doc(&self) -> Option<Doc>
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.