Expand description
Y-CRDT types re-exported for convenience when the “y-crdt” feature is enabled.
This module re-exports commonly used types from the yrs crate so that client code
doesn’t need to add yrs as a separate dependency when using YDoc.
Modules§
- any
- atomic
atomicmodule is a home for AtomicRef cell-like struct, used to perform thread-safe operations using underlying hardware intristics.- block
- branch
- doc
- encoding
- error
- iter
- json_
path - observer
- sync
- types
- undo
- updates
Macros§
Structs§
- Acquire
Transaction - Acquire
Transaction Mut - Array
Prelim - A preliminary array. It can be used to initialize an ArrayRef, when it’s about to be nested into another Yrs data collection, such as [Map] or another ArrayRef.
- Array
Ref - A collection used to store data in an indexed sequence structure. This type is internally implemented as a double linked list, which may squash values inserted directly one after another into single list node upon transaction commit.
- Delete
Set - DeleteSet contains information about all blocks (described by clock ranges) that have been subjected to delete process.
- Doc
- A Yrs document type. Documents are the most important units of collaborative resources management. All shared collections live within a scope of their corresponding documents. All updates are generated on per-document basis (rather than individual shared type). All operations on shared collections happen via Transaction, which lifetime is also bound to a document.
- Hook
- A descriptor used to reference to shared collections by their unique logical identifiers, which can be either Root-level collections or shared collections Nested into each other. It can be resolved from any shared reference using SharedRef::hook.
- ID
- Block identifier, which allows to uniquely identify any element insertion in a global scope (across different replicas of the same document). It consists of client ID (which is a unique document replica identifier) and monotonically incrementing clock value.
- Json
Path - MapPrelim
- A preliminary map. It can be used to early initialize the contents of a MapRef, when it’s about to be inserted into another Yrs collection, such as ArrayRef or another MapRef.
- MapRef
- Collection used to store key-value entries in an unordered manner. Keys are always represented as UTF-8 strings. Values can be any value type supported by Yrs: JSON-like primitives as well as shared data types.
- Nested
- A logical reference used to represent a shared collection nested within another one. Unlike Root-level types which cannot be deleted and exist eternally, Nested collections can be added (therefore don’t exist prior their instantiation) and deleted (so that any SharedRef values referencing them become unsafe and can point to objects that no longer exists!).
- Observer
- Data structure used to handle publish/subscribe callbacks of specific type. Observers perform subscriber changes in thread-safe manner, using atomic hardware intrinsics.
- Offset
- Offset is a result of mapping of StickyIndex onto document store at a current point in time.
- Options
- Configuration options of Doc instance.
- Origin
- A binary marker that can be assigned to a read-write transaction upon creation via Transact::try_transact_mut_with/Transact::transact_mut_with. It can be used to classify transaction updates within a specific context, which exists for the duration of a transaction (it’s not persisted in the document store itself), i.e. you can use unique document client identifiers to differentiate updates incoming from remote nodes from those performed locally.
- Root
- A logical reference to a root-level shared collection. It can be shared across different documents to reference the same logical type.
- Root
Refs - Iterator struct used to traverse over all of the root level types defined in a corresponding Doc.
- Snapshot
- Snapshot describes a state of a document store at a given point in (logical) time. In practice it’s a combination of StateVector (a summary of all observed insert/update operations) and a DeleteSet (a summary of all observed deletions).
- State
Vector - State vector is a compact representation of all known blocks inserted and integrated into a given document. This descriptor can be serialized and used to determine a difference between seen and unseen inserts of two replicas of the same document, potentially existing in different processes.
- Sticky
Index - A sticky index is based on the Yjs model and is not affected by document changes. E.g. If you place a sticky index before a certain character, it will always point to this character. If you place a sticky index at the end of a type, it will always point to the end of the type.
- Store
- Store is a core element of a document. It contains all of the information, like block store map of root types, pending updates waiting to be applied once a missing update information arrives and all subscribed callbacks.
- Subdocs
Event - Event used to communicate load requests from the underlying subdocuments.
- Subdocs
Event Iter - Text
Prelim - A preliminary text. It’s can be used to initialize a TextRef, when it’s about to be nested into another Yrs data collection, such as Map or Array.
- TextRef
- A shared data type used for collaborative text editing. It enables multiple users to add and remove chunks of text in efficient manner. This type is internally represented as a mutable double-linked list of text chunks - an optimization occurs during [Transaction::commit], which allows to squash multiple consecutively inserted characters together as a single chunk of text even between transaction boundaries in order to preserve more efficient memory model.
- Transaction
- A very lightweight read-only transaction. These transactions are guaranteed to not modify the contents of an underlying Doc and can be used to read it or for serialization purposes. For this reason it’s allowed to have a multiple active read-only transactions, but it’s not allowed to have any active read-write transactions at the same time.
- Transaction
Cleanup Event - Holds transaction update information from a commit after state vectors have been compressed.
- Transaction
Mut - Read-write transaction. It can be used to modify an underlying state of the corresponding Doc. Read-write transactions require an exclusive access to document store - only one such transaction can be present per Doc at the same time (read-only Transactions are not allowed to coexists at the same time as well).
- Update
- Update type which contains an information about all decoded blocks which are incoming from a remote peer. Since these blocks are not yet integrated into current document’s block store, they still may require repairing before doing so as they don’t contain full data about their relations.
- Update
Event - An update event passed to a callback subscribed with Doc::observe_update_v1/Doc::observe_update_v2.
- XmlElement
Prelim - A preliminary type that will be materialized into an XmlElementRef once it will be integrated into Yrs document.
- XmlElement
Ref - XML element data type. It represents an XML node, which can contain key-value attributes (interpreted as strings) as well as other nested XML elements or rich text (represented by XmlTextRef type).
- XmlFragment
Prelim - A preliminary type that will be materialized into an XmlFragmentRef once it will be integrated into Yrs document.
- XmlFragment
Ref - A XML fragment, which works as an untagged collection of XML nodes.
- XmlText
Prelim - A preliminary type that will be materialized into an XmlTextRef once it will be integrated into Yrs document.
- XmlText
Ref - A shared data type used for collaborative text editing, that can be used in a context of XmlElementRef node. It enables multiple users to add and remove chunks of text in efficient manner. This type is internally represented as a mutable double-linked list of text chunks
Enums§
- Any
- Any is an enum with a potentially associated value that is used to represent JSON values and supports efficient encoding of those values.
- Assoc
- Association type used by StickyIndex. In general StickyIndex refers to a cursor
space between two elements (eg. “ab.c” where “abc” is our string and
.is the StickyIndex placement). However in a situation when another peer is updating a collection concurrently, a new set of elements may be inserted into that space, expanding it in the result. In such case Assoc tells us if the StickyIndex should stick to location before or after referenced index. - BranchID
- An unique logical identifier of a shared collection. Can be shared across document boundaries to reference to the same logical entity across different replicas of a document.
- In
- A wrapper around Out type that enables it to be used as a type to be inserted into shared collections. If In contains a shared type, it will be inserted as a deep copy of the original type: therefore none of the changes applied to the original type will affect the deep copy.
- Index
Scope - Struct describing context in which StickyIndex is placed. For items pointing inside of the shared typed sequence it’s always [StickyIndex::Relative] which refers to a block ID found under corresponding position.
- Offset
Kind - Determines how string length and offsets of [Text]/[XmlText] are being determined.
- Out
- Value that can be returned by Yrs data types. This includes Any which is an extension representation of JSON, but also nested complex collaborative structures specific to Yrs.
- Transaction
AcqError - XmlOut
- A return type from XML elements retrieval methods. It’s an enum of all supported values, that can be nested inside XmlElementRef. These are other XmlElementRefs, XmlFragmentRefs or XmlTextRef values.
Traits§
- Array
- Async
Transact - Trait implemented by Doc and shared types, used for carrying over the responsibilities of creating new transactions, used as a unit of work in Yrs.
- Deep
Observable - Trait implemented by all Y-types, allowing for observing events which are emitted by nested types.
- GetString
- Trait implemented by shared types to display their contents in string format.
- Indexed
Sequence - Trait used to retrieve a StickyIndex corresponding to a given human-readable index. Unlike standard indexes StickyIndex enables to track the location inside of a shared y-types, even in the face of concurrent updates.
- Json
Path Eval - Trait implemented by types capable of evaluating JSON Paths.
- Map
- Observable
- ReadTxn
- Trait defining read capabilities present in a transaction. Implemented by both lightweight read-only and read-write transactions.
- RootRef
- A subset of SharedRef used to mark collaborative collections that can be used as a root level collections. This includes common types like ArrayRef, MapRef, TextRef and XmlFragmentRef.
- Shared
Ref - Common trait for shared collaborative collection types in Yrs.
- Text
- Transact
- Trait implemented by Doc and shared types, used for carrying over the responsibilities of creating new transactions, used as a unit of work in Yrs.
- Write
Txn - Xml
- XmlFragment
Functions§
- diff_
updates_ v1 - Givens an input
update(encoded using lib0 v1 encoding) of document A and an encodedstate_vectorof document B, returns a lib0 v1 encoded update, that contains all changes from A which have not been observed by B (based on its state vector). - diff_
updates_ v2 - Givens an input
update(encoded using lib0 v2 encoding) of document A and an encodedstate_vectorof document B, returns a lib0 v2 encoded update, that contains all changes from A which have not been observed by B (based on its state vector). - encode_
state_ vector_ from_ update_ v1 - Decodes a input
update(encoded using lib0 v1 encoding) and returns an encoded StateVector of that update. - encode_
state_ vector_ from_ update_ v2 - Decodes a input
update(encoded using lib0 v2 encoding) and returns an encoded StateVector of that update. - merge_
updates_ v1 - Merges a sequence of updates (encoded using lib0 v1 encoding) together, producing another
update (also lib0 v1 encoded) in the result. Returned binary is a combination of all input
updates, compressed. - merge_
updates_ v2 - Merges a sequence of updates (encoded using lib0 v2 encoding) together, producing another
update (also lib0 v2 encoded) in the result. Returned binary is a combination of all input
updates, compressed. - uuid_v4
- Generate random v4 UUID. (See: https://www.rfc-editor.org/rfc/rfc4122#section-4.4)
- uuid_
v4_ from - Generate random v4 UUID. (See: https://www.rfc-editor.org/rfc/rfc4122#section-4.4)
Type Aliases§
- Subscription
- Subscription handle returned by Observer::subscribe methods, which will unsubscribe corresponding callback when dropped.
- Undo
Manager - Uuid
- Value
Deprecated