Crate yrs

Source

Structs§

ArrayIter
Iterator structure used by shared array data type.
Attributes
Iterator structure used by XML nodes (elements and text) to iterate over node’s attributes. Attribute iterators are unordered - there’s no specific order in which map entries will be returned during consecutive iterator calls.
JsonPathIter
Iterator structure used by json path queries to traverse over the results of a query.
MapIter
Iterator structure used by shared map data type. Map iterators are unordered - there’s no specific order in which map entries will be returned during consecutive iterator calls.
Transaction
Transaction is one of the core types in Yrs. All operations that need to touch or modify a document’s contents (a.k.a. block store), need to be executed in scope of a transaction.
TreeWalker
Iterator used to traverse over the complex nested tree structure of a XML node. XML node iterator walks only over YXmlElement and YXmlText nodes. It does so in ordered manner (using the order in which children are ordered within their parent nodes) and using depth-first traverse.
WeakIter
Iterator structure used by yweak_iter function call.
YAfterTransactionEvent
Event generated for callbacks subscribed using ydoc_observe_after_transaction. It contains snapshot of changes made within any committed transaction.
YArrayEvent
Event pushed into callbacks registered with yarray_observe function. It contains delta of all content changes made within a scope of corresponding transaction (see: yarray_event_delta) as well as navigation data used to identify a YArray instance which triggered this event.
YBranchId
A structure representing logical identifier of a specific shared collection. Can be obtained by ybranch_id executed over alive Branch.
YChunk
A chunk of text contents formatted with the same set of attributes.
YDeleteSet
Delete set is a map of (ClientID, Range[]) entries. Length of a map is stored in entries_count field. ClientIDs reside under client_ids and their corresponding range sequences can be found under the same index of ranges field.
YDeltaAttr
A single instance of formatting attribute stored as part of YDelta instance.
YDeltaIn
A data type representing a single change to be performed in sequence of changes defined as parameter to a ytext_insert_delta function. A type of change can be detected using a tag field:
YDeltaOut
A data type representing a single change detected over an observed YText/YXmlText. A type of change can be detected using a tag field:
YEvent
YEventChange
A data type representing a single change detected over an observed shared collection. A type of change can be detected using a tag field:
YEventKeyChange
A data type representing a single change made over a map component of shared collection types, such as YMap entries or YXmlText/YXmlElement attributes. A key field provides a corresponding unique key string of a changed entry, while tag field informs about specific type of change being done:
YIdRange
YIdRangeSeq
Fixed-length sequence of ID ranges. Each range is a pair of [start, end) values, describing the range of items identified by clock values, that this range refers to.
YInput
A data structure that is used to pass input values of various types supported by Yrs into a shared document store.
YMapEntry
A structure representing single key-value entry of a map output (used by either embedded JSON-like maps or YMaps).
YMapEvent
Event pushed into callbacks registered with ymap_observe function. It contains all key-value changes made within a scope of corresponding transaction (see: ymap_event_keys) as well as navigation data used to identify a YMap instance which triggered this event.
YOptions
Configuration object used by YDoc.
YOutput
An output value cell returned from yrs API methods. It describes a various types of data supported by yrs shared data types.
YPathSegment
A single segment of a path returned from yevent_path function. It can be one of two cases, recognized by it’s tag field:
YPendingUpdate
Structure containing unapplied update data. Created via ytransaction_pending_update. Released via ypending_update_destroy.
YStateVector
Struct representing a state of a document. It contains the last seen clocks for blocks submitted per any of the clients collaborating on document updates.
YStickyIndex
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.
YSubdocsEvent
YTextEvent
Event pushed into callbacks registered with ytext_observe function. It contains delta of all text changes made within a scope of corresponding transaction (see: ytext_event_delta) as well as navigation data used to identify a YText instance which triggered this event.
YUndoEvent
Event type related to UndoManager observer operations, such as yundo_manager_observe_popped and yundo_manager_observe_added. It contains various informations about the context in which undo/redo operations are executed.
YUndoManagerOptions
YWeakLinkEvent
Event pushed into callbacks registered with yweak_observe function. It contains all an event changes of the underlying transaction.
YXmlAttr
A structure representing single attribute of an either YXmlElement or YXmlText instance. It consists of attribute name and string, both of which are null-terminated UTF-8 strings.
YXmlEvent
Event pushed into callbacks registered with yxmlelem_observe function. It contains all attribute changes made within a scope of corresponding transaction (see: yxmlelem_event_keys) as well as child XML nodes changes (see: yxmlelem_event_delta) and navigation data used to identify a YXmlElement instance which triggered this event.
YXmlTextEvent
Event pushed into callbacks registered with yxmltext_observe function. It contains all attribute changes made within a scope of corresponding transaction (see: yxmltext_event_keys) as well as text edits (see: yxmltext_event_delta) and navigation data used to identify a YXmlText instance which triggered this event.

Constants§

ERR_CODE_EOS
Error code: end of stream found when more data was expected.
ERR_CODE_INVALID_JSON
Error code: failure when trying to decode JSON content.
ERR_CODE_IO
Error code: couldn’t read data from input stream.
ERR_CODE_OTHER
Error code: other error type than the one specified.
ERR_CODE_UNEXPECTED_VALUE
Error code: decoded enum tag value was not among known cases.
ERR_CODE_VAR_INT
Error code: decoded variable integer outside of the expected integer size bounds.
ERR_CUSTOM
Error code: miscellaneous error coming from serde, not covered by other error codes.
ERR_INVALID_PARENT
Error code: update block assigned to parent that is not a valid shared ref of deleted block.
ERR_NOT_ENOUGH_MEMORY
Error code: not enough memory to perform an operation.
ERR_TYPE_MISMATCH
Error code: conversion attempt to specific Rust type was not possible.
YCHANGE_ADD
YCHANGE_REMOVE
YCHANGE_RETAIN
Y_ARRAY
Flag used by YInput and YOutput to tag content, which is an YArray shared type.
Y_DOC
Flag used by YInput and YOutput to tag content, which is an YDoc shared type.
Y_EVENT_CHANGE_ADD
Tag used to identify YEventChange (see: yevent_delta function) case, when a new element has been added to an observed collection.
Y_EVENT_CHANGE_DELETE
Tag used to identify YEventChange (see: yevent_delta function) case, when an existing element has been removed from an observed collection.
Y_EVENT_CHANGE_RETAIN
Tag used to identify YEventChange (see: yevent_delta function) case, when no changes have been detected for a particular range of observed collection.
Y_EVENT_KEY_CHANGE_ADD
Tag used to identify YEventKeyChange (see: yevent_keys function) case, when a new entry has been inserted into a map component of shared collection.
Y_EVENT_KEY_CHANGE_DELETE
Tag used to identify YEventKeyChange (see: yevent_keys function) case, when an existing entry has been removed from a map component of shared collection.
Y_EVENT_KEY_CHANGE_UPDATE
Tag used to identify YEventKeyChange (see: yevent_keys function) case, when an existing entry has been overridden with a new value within a map component of shared collection.
Y_EVENT_PATH_INDEX
Tag used to identify YPathSegment storing an int parameter.
Y_EVENT_PATH_KEY
Tag used to identify YPathSegment storing a *char parameter.
Y_FALSE
Flag used to mark a falsy boolean numbers.
Y_JSON
Flag used by YInput to pass JSON string for an object that should be deserialized and stored internally as fully fledged scalar type.
Y_JSON_ARR
Flag used by YInput and YOutput to tag embedded JSON-like arrays of values, which themselves are YInput and YOutput instances respectively.
Y_JSON_BOOL
Flag used by YInput and YOutput to tag boolean values.
Y_JSON_BUF
Flag used by YInput and YOutput to tag binary content.
Y_JSON_INT
Flag used by YInput and YOutput to tag 64-bit integer numbers.
Y_JSON_MAP
Flag used by YInput and YOutput to tag embedded JSON-like maps of key-value pairs, where keys are strings and v
Y_JSON_NULL
Flag used by YInput and YOutput to tag JSON-like null values.
Y_JSON_NUM
Flag used by YInput and YOutput to tag floating point numbers.
Y_JSON_STR
Flag used by YInput and YOutput to tag strings.
Y_JSON_UNDEF
Flag used by YInput and YOutput to tag JSON-like undefined values.
Y_KIND_REDO
Y_KIND_UNDO
Y_MAP
Flag used by YInput and YOutput to tag content, which is an YMap shared type.
Y_OFFSET_BYTES
Flag used by YOptions to determine, that text operations offsets and length will be counted by the byte number of UTF8-encoded string.
Y_OFFSET_UTF16
Flag used by YOptions to determine, that text operations offsets and length will be counted by UTF-16 chars of encoded string.
Y_TEXT
Flag used by YInput and YOutput to tag content, which is an YText shared type.
Y_TRUE
Flag used to mark a truthy boolean numbers.
Y_UNDEFINED
Flag used by YOutput to tag content, which is an undefined shared type. This usually happens when it’s referencing a root type that has not been initalized localy.
Y_WEAK_LINK
Flag used by YInput and YOutput to tag content, which is an YWeakLink shared type.
Y_XML_ELEM
Flag used by YInput and YOutput to tag content, which is an YXmlElement shared type.
Y_XML_FRAG
Flag used by YInput and YOutput to tag content, which is an YXmlFragment shared type.
Y_XML_TEXT
Flag used by YInput and YOutput to tag content, which is an YXmlText shared type.

Functions§

yarray
Gets or creates a new shared YArray data type instance as a root-level type of a given document. This structure can later be accessed using its name, which must be a null-terminated UTF-8 compatible string.
yarray_event_delta
Returns a sequence of changes produced by sequence component of shared collections (such as YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to provide information about number of changes produced.
yarray_event_path
Returns a path from a root type down to a current shared collection (which can be obtained using yarray_event_target function). It can consist of either integer indexes (used by sequence components) or *char keys (used by map components). len output parameter is used to provide information about length of the path.
yarray_event_target
Returns a pointer to a shared collection, which triggered passed event e.
yarray_get
Returns a pointer to a YOutput value stored at a given index of a current YArray. If index is outside the bounds of an array, a null pointer will be returned.
yarray_get_json
Returns a UTF-8 encoded, NULL-terminated JSON string representing a value stored in a current YArray under a given index.
yarray_insert_range
Inserts a range of items into current YArray, starting at given index. An items_len parameter is used to determine the size of items array - it can also be used to insert a single element given its pointer.
yarray_iter
Returns an iterator, which can be used to traverse over all elements of an array (array’s length can be determined using yarray_len function).
yarray_iter_destroy
Releases all of an YArray iterator resources created by calling yarray_iter.
yarray_iter_next
Moves current YArray iterator over to a next element, returning a pointer to it. If an iterator comes to an end of an array, a null pointer will be returned.
yarray_len
Returns a number of elements stored within current instance of YArray.
yarray_move
yarray_observe
Subscribes a given callback function cb to changes made by this YArray instance. Callbacks are triggered whenever a ytransaction_commit is called. Returns a subscription ID which can be then used to unsubscribe this callback by using yunobserve function.
yarray_quote
yarray_remove_range
Removes a len of consecutive range of elements from current array instance, starting at a given index. Range determined by index and len must fit into boundaries of an array, otherwise it will panic at runtime.
ybinary_destroy
Frees all memory-allocated resources bound to a given binary returned from Yrs document API. Unlike strings binaries are not null-terminated and can contain null characters inside, therefore a size of memory to be released must be explicitly provided. Yrs binaries don’t use libc malloc, so calling free() on them will fault.
ybranch_alive
Check if current branch is still alive (returns Y_TRUE, otherwise Y_FALSE). If it was deleted, this branch pointer is no longer a valid pointer and cannot be used to execute any functions using it.
ybranch_get
Given a logical identifier, returns a physical pointer to a shared collection. Returns null if collection was not found - either because it was not defined or not synchronized yet. Returned pointer may still point to deleted collection. In such case a subsequent ybranch_alive function call is required.
ybranch_id
Returns a logical identifier for a given shared collection. That collection must be alive at the moment of function call.
ybranch_json
Returns a UTF-8 encoded, NULL-terminated JSON string representation of the current branch contents. Once no longer needed, this string must be explicitly deallocated by user using ystring_destroy.
ychunks_destroy
Deallocates result of ytext_chunks method.
ydelete_set_destroy
ydelta_input_delete
Creates a parameter for ytext_insert_delta function. This parameter will tell cursor to remove a corresponding number of elements, starting from current cursor position.
ydelta_input_insert
Creates a parameter for ytext_insert_delta function. This parameter will tell cursor to insert given elements into current cursor position. While these elements can be of any type (used for embedding ie. shared types or binary payload like images), for the text insertion a yinput_string is expected. If formatting attributes were specified, inserted elements will be wrapped by given formatting attributes.
ydelta_input_retain
Creates a parameter for ytext_insert_delta function. This parameter will move cursor position by the len of elements. If formatting attrs were defined, all elements skipped over this way will be wrapped by given formatting attributes.
ydoc_auto_load
Returns status of auto_load flag of this Doc instance. Auto loaded sub-documents automatically send a load request to their parent documents.
ydoc_clear
Destroys current document, sending a ‘destroy’ event and clearing up all the event callbacks registered.
ydoc_clone
Creates a shallow clone of a provided doc - it’s realized by increasing the ref-count value of the document. In result both input and output documents point to the same instance.
ydoc_collection_id
Returns a collection identifier of this Doc instance. If none was defined, a NULL will be returned.
ydoc_destroy
Releases all memory-allocated resources bound to given document.
ydoc_guid
Returns a unique document identifier of this Doc instance.
ydoc_id
Returns a unique client identifier of this Doc instance.
ydoc_load
Manually send a load request to a parent document of this subdoc.
ydoc_new
Creates a new Doc instance with a randomized unique client identifier.
ydoc_new_with_options
Creates a new Doc instance with a specified options.
ydoc_observe_after_transaction
ydoc_observe_clear
ydoc_observe_subdocs
ydoc_observe_updates_v1
ydoc_observe_updates_v2
ydoc_read_transaction
Starts a new read-only transaction on a given document. All other operations happen in context of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is complete, a transaction can be finished using ytransaction_commit function.
ydoc_should_load
Returns status of should_load flag of this Doc instance, informing parent Doc if this document instance requested a data load.
ydoc_write_transaction
Starts a new read-write transaction on a given document. All other operations happen in context of a transaction. Yrs transactions do not follow ACID rules. Once a set of operations is complete, a transaction can be finished using ytransaction_commit function.
yevent_delta_destroy
Releases memory allocated by the object returned from yevent_delta function.
yevent_keys_destroy
Releases memory allocated by the object returned from yxml_event_keys and ymap_event_keys functions.
yinput_binary
Function constructor used to create a binary YInput cell of a specified length. This function doesn’t allocate any heap resources and doesn’t release any on its own, therefore its up to a caller to free resources once a structure is no longer needed.
yinput_bool
Function constructor used to create JSON-like boolean YInput cell. This function doesn’t allocate any heap resources.
yinput_float
Function constructor used to create JSON-like 64-bit floating point number YInput cell. This function doesn’t allocate any heap resources.
yinput_json
Function constructor used to create aa YInput cell representing any JSON-like object. Provided parameter must be a null-terminated UTF-8 encoded JSON string.
yinput_json_array
Function constructor used to create a JSON-like array YInput cell of other JSON-like values of a given length. This function doesn’t allocate any heap resources and doesn’t release any on its own, therefore its up to a caller to free resources once a structure is no longer needed.
yinput_json_map
Function constructor used to create a JSON-like map YInput cell of other JSON-like key-value pairs. These pairs are build from corresponding indexes of keys and values, which must have the same specified length.
yinput_long
Function constructor used to create JSON-like 64-bit signed integer YInput cell. This function doesn’t allocate any heap resources.
yinput_null
Function constructor used to create JSON-like NULL YInput cell. This function doesn’t allocate any heap resources.
yinput_string
Function constructor used to create a string YInput cell. Provided parameter must be a null-terminated UTF-8 encoded string. This function doesn’t allocate any heap resources, and doesn’t release any on its own, therefore its up to a caller to free resources once a structure is no longer needed.
yinput_undefined
Function constructor used to create JSON-like undefined YInput cell. This function doesn’t allocate any heap resources.
yinput_weak
Function constructor used to create a string YInput cell with weak reference to another element(s) living inside of the same document.
yinput_yarray
Function constructor used to create a nested YArray YInput cell prefilled with other values of a given length. This function doesn’t allocate any heap resources and doesn’t release any on its own, therefore its up to a caller to free resources once a structure is no longer needed.
yinput_ydoc
Function constructor used to create a nested YDoc YInput cell.
yinput_ymap
Function constructor used to create a nested YMap YInput cell prefilled with other key-value pairs. These pairs are build from corresponding indexes of keys and values, which must have the same specified length.
yinput_ytext
Function constructor used to create a nested YText YInput cell prefilled with a specified string, which must be a null-terminated UTF-8 character pointer.
yinput_yxmlelem
Function constructor used to create a nested YXmlElement YInput cell with a specified tag name, which must be a null-terminated UTF-8 character pointer.
yinput_yxmltext
Function constructor used to create a nested YXmlText YInput cell prefilled with a specified string, which must be a null-terminated UTF-8 character pointer.
yjson_path_iter_destroy
Closes the JSON path iterator created via ytransaction_json_path and releases its resources.
yjson_path_iter_next
Returns the next element of a JSON path iterator. If there are no more elements, NULL is returned.
ymap
Gets or creates a new shared YMap data type instance as a root-level type of a given document. This structure can later be accessed using its name, which must be a null-terminated UTF-8 compatible string.
ymap_entry_destroy
Frees all memory-allocated resources bound to a given YMapEntry.
ymap_event_keys
Returns a sequence of changes produced by map component of shared collections (such as YMap and YXmlText/YXmlElement attribute changes). len output parameter is used to provide information about number of changes produced.
ymap_event_path
Returns a path from a root type down to a current shared collection (which can be obtained using ymap_event_target function). It can consist of either integer indexes (used by sequence components) or *char keys (used by map components). len output parameter is used to provide information about length of the path.
ymap_event_target
Returns a pointer to a shared collection, which triggered passed event e.
ymap_get
Returns a value stored under the provided key, or a null pointer if no entry with such key has been found in a current map. A returned value is allocated by this function and therefore should be eventually released using youtput_destroy function.
ymap_get_json
Returns a value stored under the provided key as UTF-8 encoded, NULL-terminated JSON string. Once not needed that string should be deallocated using ystring_destroy.
ymap_insert
Inserts a new entry (specified as key-value pair) into a current map. If entry under such given key already existed, its corresponding value will be replaced.
ymap_iter
Returns an iterator, which can be used to traverse over all key-value pairs of a map.
ymap_iter_destroy
Releases all of an YMap iterator resources created by calling ymap_iter.
ymap_iter_next
Moves current YMap iterator over to a next entry, returning a pointer to it. If an iterator comes to an end of a map, a null pointer will be returned. Yrs maps are unordered and so are their iterators.
ymap_len
Returns a number of entries stored within a map.
ymap_link
ymap_observe
Subscribes a given callback function cb to changes made by this YMap instance. Callbacks are triggered whenever a ytransaction_commit is called. Returns a subscription ID which can be then used to unsubscribe this callback by using yunobserve function.
ymap_remove
Removes a map entry, given its key. Returns 1 if the corresponding entry was successfully removed or 0 if no entry with a provided key has been found inside of a map.
ymap_remove_all
Removes all entries from a current map.
yobserve_deep
Subscribes a given callback function cb to changes made by this shared type instance as well as all nested shared types living within it. Callbacks are triggered whenever a ytransaction_commit is called.
yoptions
Returns default ceonfiguration for YOptions.
youtput_destroy
Releases all resources related to a corresponding YOutput cell.
youtput_read_binary
Attempts to read the value for a given YOutput pointer as a binary payload (which length is stored within len filed of a cell itself).
youtput_read_bool
Attempts to read the value for a given YOutput pointer as a boolean flag, which can be either 1 for truthy case and 0 otherwise. Returns a null pointer in case when a value stored under current YOutput cell is not of a boolean type.
youtput_read_float
Attempts to read the value for a given YOutput pointer as a 64-bit floating point number.
youtput_read_json_array
Attempts to read the value for a given YOutput pointer as a JSON-like array of YOutput values (which length is stored within len filed of a cell itself).
youtput_read_json_map
Attempts to read the value for a given YOutput pointer as a JSON-like map of key-value entries (which length is stored within len filed of a cell itself).
youtput_read_long
Attempts to read the value for a given YOutput pointer as a 64-bit signed integer.
youtput_read_string
Attempts to read the value for a given YOutput pointer as a null-terminated UTF-8 encoded string.
youtput_read_yarray
Attempts to read the value for a given YOutput pointer as an YArray.
youtput_read_ydoc
Attempts to read the value for a given YOutput pointer as a YDocRef reference to a nested document.
youtput_read_ymap
Attempts to read the value for a given YOutput pointer as an YMap.
youtput_read_ytext
Attempts to read the value for a given YOutput pointer as an YText.
youtput_read_yweak
Attempts to read the value for a given YOutput pointer as an YWeakRef.
youtput_read_yxmlelem
Attempts to read the value for a given YOutput pointer as an YXmlElement.
youtput_read_yxmltext
Attempts to read the value for a given YOutput pointer as an YXmlText.
ypath_destroy
Releases allocated memory used by objects returned from path accessor functions of shared type events.
ypending_update_destroy
ysticky_index_assoc
Returns association of current YStickyIndex. If association is after the referenced inserted character, returned number will be >= 0. If association is before the referenced inserted character, returned number will be < 0.
ysticky_index_decode
Serializes YStickyIndex into JSON representation. len parameter is updated with byte length of the generated binary. Returned binary can be free’d using ybinary_destroy.
ysticky_index_destroy
Releases resources allocated by YStickyIndex pointers.
ysticky_index_encode
Serializes YStickyIndex into binary representation. len parameter is updated with byte length of the generated binary. Returned binary can be free’d using ybinary_destroy.
ysticky_index_from_index
Retrieves a YStickyIndex corresponding to a given human-readable index pointing into the shared y-type branch. Unlike standard indexes sticky one enables to track the location inside of a shared y-types, even in the face of concurrent updates.
ysticky_index_from_json
Deserializes YStickyIndex from the payload previously serialized using ysticky_index_to_json. The input json parameter is a NULL-terminated UTF-8 encoded string containing a JSON compatible with Yjs RelativePosition serialization format.
ysticky_index_read
Given YStickyIndex and transaction reference, if computes a human-readable index in a context of the referenced shared y-type.
ysticky_index_to_json
Serialize YStickyIndex into null-terminated UTF-8 encoded JSON string, that’s compatible with Yjs RelativePosition serialization format. The len parameter is updated with byte length of of the output JSON string. This string can be freed using ystring_destroy.
ystring_destroy
Frees all memory-allocated resources bound to a given UTF-8 null-terminated string returned from Yrs document API. Yrs strings don’t use libc malloc, so calling free() on them will fault.
ytext
Gets or creates a new shared YText data type instance as a root-level type of a given document. This structure can later be accessed using its name, which must be a null-terminated UTF-8 compatible string.
ytext_chunks
Returns a collection of chunks representing pieces of YText rich text string grouped together by the same formatting rules and type. chunks_len is used to inform about a number of chunks generated this way.
ytext_delta_destroy
Releases memory allocated by the object returned from ytext_delta function.
ytext_event_delta
Returns a sequence of changes produced by sequence component of shared collections (such as YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to provide information about number of changes produced.
ytext_event_path
Returns a path from a root type down to a current shared collection (which can be obtained using ytext_event_target function). It can consist of either integer indexes (used by sequence components) or *char keys (used by map components). len output parameter is used to provide information about length of the path.
ytext_event_target
Returns a pointer to a shared collection, which triggered passed event e.
ytext_format
Wraps an existing piece of text within a range described by index-len parameters with formatting blocks containing provided attrs metadata. attrs must be a map-like type.
ytext_insert
Inserts a null-terminated UTF-8 encoded string a given index. index value must be between 0 and a length of a YText (inclusive, accordingly to ytext_len return value), otherwise this function will panic.
ytext_insert_delta
Performs a series of changes over the given YText shared ref type, described by the delta parameter:
ytext_insert_embed
Inserts an embed content given index. index value must be between 0 and a length of a YText (inclusive, accordingly to ytext_len return value), otherwise this function will panic.
ytext_len
Returns the length of the YText string content in bytes (without the null terminator character)
ytext_observe
Subscribes a given callback function cb to changes made by this YText instance. Callbacks are triggered whenever a ytransaction_commit is called. Returns a subscription ID which can be then used to unsubscribe this callback by using yunobserve function.
ytext_quote
ytext_remove_range
Removes a range of characters, starting a a given index. This range must fit within the bounds of a current YText, otherwise this function call will fail.
ytext_string
Returns a null-terminated UTF-8 encoded string content of a current YText shared data type.
ytransaction_apply
Applies an diff update (generated by ytransaction_state_diff_v1) to a local transaction’s document.
ytransaction_apply_v2
Applies an diff update (generated by ytransaction_state_diff_v2) to a local transaction’s document.
ytransaction_commit
Commit and dispose provided read-write transaction. This operation releases allocated resources, triggers update events and performs a storage compression over all operations executed in scope of a current transaction.
ytransaction_encode_state_from_snapshot_v1
Encodes a state of the document at a point in time specified by the provided snapshot (generated by: ytransaction_snapshot). This is useful to generate a past view of the document.
ytransaction_encode_state_from_snapshot_v2
Encodes a state of the document at a point in time specified by the provided snapshot (generated by: ytransaction_snapshot). This is useful to generate a past view of the document.
ytransaction_force_gc
Perform garbage collection of deleted blocks, even if a document was created with skip_gc option. This operation will scan over ALL deleted elements, NOT ONLY the ones that have been changed as part of this transaction scope.
ytransaction_json_path
Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on the transaction’s document and returns an iterator over values matching that query.
ytransaction_pending_ds
Returns an unapplied Delete Set for the current document, waiting for missing updates in order to be integrated into document store.
ytransaction_pending_update
Returns a pending update associated with an underlying YDoc. Pending update contains update data waiting for being integrated into main document store. Usually reason for that is that there were missing updates required for integration. In such cases they need to arrive and be integrated first.
ytransaction_snapshot
Returns a snapshot descriptor of a current state of the document. This snapshot information can be then used to encode document data at a particular point in time (see: ytransaction_encode_state_from_snapshot).
ytransaction_state_diff_v1
Returns a delta difference between current state of a transaction’s document and a state vector sv encoded as a binary payload using lib0 version 1 encoding (which could be generated using ytransaction_state_vector_v1). Such delta can be send back to the state vector’s sender in order to propagate and apply (using ytransaction_apply) all updates known to a current document, which remote peer was not aware of.
ytransaction_state_diff_v2
Returns a delta difference between current state of a transaction’s document and a state vector sv encoded as a binary payload using lib0 version 1 encoding (which could be generated using ytransaction_state_vector_v1). Such delta can be send back to the state vector’s sender in order to propagate and apply (using ytransaction_apply_v2) all updates known to a current document, which remote peer was not aware of.
ytransaction_state_vector_v1
Returns a state vector of a current transaction’s document, serialized using lib0 version 1 encoding. Payload created by this function can then be send over the network to a remote peer, where it can be used as a parameter of ytransaction_state_diff_v1 in order to produce a delta update payload, that can be send back and applied locally in order to efficiently propagate updates from one peer to another.
ytransaction_subdocs
Returns a list of subdocs existing within current document.
ytransaction_writeable
Returns 1 if current transaction is of read-write type. Returns 0 if transaction is read-only.
ytype_get
Gets a reference to shared data type instance at the document root-level, identified by its name, which must be a null-terminated UTF-8 compatible string.
ytype_kind
Returns a value informing what kind of Yrs shared collection given branch represents. Returns either 0 when branch is null or one of values: Y_ARRAY, Y_TEXT, Y_MAP, Y_XML_ELEM, Y_XML_TEXT.
yundo_manager
Creates a new instance of undo manager bound to a current doc. It can be used to track specific shared refs via yundo_manager_add_scope and updates coming from specific origin
yundo_manager_add_origin
Adds an origin to be tracked by current undo manager. This way only changes made within context of transactions created with specific origin will be subjects of undo/redo operations. This is useful when you want to be able to revert changed done by specific user without reverting changes made by other users that were applied in the meantime.
yundo_manager_add_scope
Add specific shared type to be tracked by this instance of an undo manager.
yundo_manager_clear
Removes all the undo/redo stack changes tracked by current undo manager. This also cleans up all the items that couldn’t be deallocated / garbage collected for the sake of possible undo/redo operations.
yundo_manager_destroy
Deallocated undo manager instance created via yundo_manager.
yundo_manager_observe_added
Subscribes a callback function pointer to a given undo manager event. This event will be triggered every time a new undo/redo stack item is added.
yundo_manager_observe_popped
Subscribes a callback function pointer to a given undo manager event. This event will be triggered every time a undo/redo operation was called.
yundo_manager_redo
Performs a redo operations, reapplying changes undone by yundo_manager_undo operation.
yundo_manager_redo_stack_len
Returns number of elements stored on redo stack.
yundo_manager_remove_origin
Removes an origin previously added to undo manager via yundo_manager_add_origin.
yundo_manager_stop
Cuts off tracked changes, producing a new stack item on undo stack.
yundo_manager_undo
Performs an undo operations, reverting all the changes defined by the last undo stack item. These changes can be then reapplied again by calling yundo_manager_redo function.
yundo_manager_undo_stack_len
Returns number of elements stored on undo stack.
yunobserve
Unsubscribe callback from the oberver event it was previously subscribed to.
yupdate_debug_v1
Returns a null-terminated UTF-8 encoded string representation of an update binary payload, encoded using lib0 v1 encoding. Returns null if update couldn’t be parsed into a lib0 v1 formatting.
yupdate_debug_v2
Returns a null-terminated UTF-8 encoded string representation of an update binary payload, encoded using lib0 v2 encoding. Returns null if update couldn’t be parsed into a lib0 v2 formatting.
yweak_deref
yweak_destroy
yweak_iter
yweak_iter_destroy
yweak_iter_next
yweak_observe
Subscribes a given callback function cb to changes made by this YText instance. Callbacks are triggered whenever a ytransaction_commit is called. Returns a subscription ID which can be then used to unsubscribe this callback by using yunobserve function.
yweak_read
yweak_string
yweak_xml_string
yxml_next_sibling
Returns a next sibling of a current XML node, which can be either another YXmlElement or a YXmlText. Together with yxmlelem_first_child it may be used to iterate over the direct children of an XML node (in order to iterate over the nested XML structure use yxmlelem_tree_walker).
yxml_prev_sibling
Returns a previous sibling of a current XML node, which can be either another YXmlElement or a YXmlText.
yxmlattr_destroy
Frees all memory-allocated resources bound to a given YXmlAttr.
yxmlattr_iter_destroy
Releases all of attributes iterator resources created by calling yxmlelem_attr_iter or yxmltext_attr_iter.
yxmlattr_iter_next
Returns a next XML attribute from an iterator. Attributes are returned in an unordered manner. Once iterator reaches the end of attributes collection, a null pointer will be returned.
yxmlelem_attr_iter
Returns an iterator over the YXmlElement attributes.
yxmlelem_child_len
Returns a number of child nodes (both YXmlElement and YXmlText) living under a current XML element. This function doesn’t count a recursive nodes, only direct children of a current node.
yxmlelem_event_delta
Returns a sequence of changes produced by sequence component of shared collections (such as YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to provide information about number of changes produced.
yxmlelem_event_keys
Returns a sequence of changes produced by map component of shared collections. len output parameter is used to provide information about number of changes produced.
yxmlelem_event_path
Returns a path from a root type down to a current shared collection (which can be obtained using yxmlelem_event_path function). It can consist of either integer indexes (used by sequence components) or *char keys (used by map components). len output parameter is used to provide information about length of the path.
yxmlelem_event_target
Returns a pointer to a shared collection, which triggered passed event e.
yxmlelem_first_child
Returns a first child node of a current YXmlElement, or null pointer if current XML node is empty. Returned value could be either another YXmlElement or YXmlText.
yxmlelem_get
Returns an XML child node (either a YXmlElement or YXmlText) stored at a given index of a current YXmlElement. Returns null pointer if index was outside of the bound of current XML node children.
yxmlelem_get_attr
Returns the value of a current YXmlElement, given its name, or a null pointer if not attribute with such name has been found. Returned pointer is a null-terminated UTF-8 encoded string, which should be released using ystring_destroy function.
yxmlelem_insert_attr
Inserts an XML attribute described using attr_name and attr_value. If another attribute with the same name already existed, its value will be replaced with a provided one.
yxmlelem_insert_elem
Inserts an YXmlElement as a child of a current node at the given index and returns its pointer. Node created this way will have a given name as its tag (eg. p for <p></p> node).
yxmlelem_insert_text
Inserts an YXmlText as a child of a current node at the given index and returns its pointer.
yxmlelem_observe
Subscribes a given callback function cb to changes made by this YXmlElement instance. Callbacks are triggered whenever a ytransaction_commit is called. Returns a subscription ID which can be then used to unsubscribe this callback by using yunobserve function.
yxmlelem_parent
Returns a parent YXmlElement of a current node, or null pointer when current YXmlElement is a root-level shared data type.
yxmlelem_remove_attr
Removes an attribute from a current YXmlElement, given its name.
yxmlelem_remove_range
Removes a consecutive range of child elements (of specified length) from the current YXmlElement, starting at the given index. Specified range must fit into boundaries of current XML node children, otherwise this function will panic at runtime.
yxmlelem_string
Converts current YXmlElement together with its children and attributes into a flat string representation (no padding) eg. <UNDEFINED><title key="value">sample text</title></UNDEFINED>.
yxmlelem_tag
Return a name (or an XML tag) of a current YXmlElement. Root-level XML nodes use “UNDEFINED” as their tag names.
yxmlelem_tree_walker
Returns an iterator over a nested recursive structure of a current YXmlElement, starting from first of its children. Returned values can be either YXmlElement or YXmlText nodes.
yxmlelem_tree_walker_destroy
Releases resources associated with a current XML tree walker iterator.
yxmlelem_tree_walker_next
Moves current iterator to a next value (either YXmlElement or YXmlText), returning its pointer or a null, if an iterator already reached the last successor node.
yxmlfragment
Gets or creates a new shared YXmlElement data type instance as a root-level type of a given document. This structure can later be accessed using its name, which must be a null-terminated UTF-8 compatible string.
yxmltext_attr_iter
Returns an iterator over the YXmlText attributes.
yxmltext_event_delta
Returns a sequence of changes produced by sequence component of shared collections (such as YText, YXmlText and XML nodes added to YXmlElement). len output parameter is used to provide information about number of changes produced.
yxmltext_event_keys
Returns a sequence of changes produced by map component of shared collections. len output parameter is used to provide information about number of changes produced.
yxmltext_event_path
Returns a path from a root type down to a current shared collection (which can be obtained using yxmltext_event_path function). It can consist of either integer indexes (used by sequence components) or *char keys (used by map components). len output parameter is used to provide information about length of the path.
yxmltext_event_target
Returns a pointer to a shared collection, which triggered passed event e.
yxmltext_format
Wraps an existing piece of text within a range described by index-len parameters with formatting blocks containing provided attrs metadata. attrs must be a map-like type.
yxmltext_get_attr
Returns the value of a current YXmlText, given its name, or a null pointer if not attribute with such name has been found. Returned pointer is a null-terminated UTF-8 encoded string, which should be released using ystring_destroy function.
yxmltext_insert
Inserts a null-terminated UTF-8 encoded string a a given index. index value must be between 0 and a length of a YXmlText (inclusive, accordingly to yxmltext_len return value), otherwise this function will panic.
yxmltext_insert_attr
Inserts an XML attribute described using attr_name and attr_value. If another attribute with the same name already existed, its value will be replaced with a provided one.
yxmltext_insert_embed
Inserts an embed content given index. index value must be between 0 and a length of a YXmlText (inclusive, accordingly to ytext_len return value), otherwise this function will panic.
yxmltext_len
Returns the length of the YXmlText string content in bytes (without the null terminator character)
yxmltext_observe
Subscribes a given callback function cb to changes made by this YXmlText instance. Callbacks are triggered whenever a ytransaction_commit is called. Returns a subscription ID which can be then used to unsubscribe this callback by using yunobserve function.
yxmltext_remove_attr
Removes an attribute from a current YXmlText, given its name.
yxmltext_remove_range
Removes a range of characters, starting a a given index. This range must fit within the bounds of a current YXmlText, otherwise this function call will fail.
yxmltext_string
Returns a null-terminated UTF-8 encoded string content of a current YXmlText shared data type.

Type Aliases§

Branch
A common shared data type. All Yrs instances can be refered to using this data type (use ytype_kind function if a specific type needs to be determined). Branch pointers are passed over type-specific functions like ytext_insert, yarray_insert or ymap_insert to perform a specific shared type operations.
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 YTransaction, which lifetime is also bound to a document.
Subscription
Subscription to any kind of observable events, like ymap_observe, ydoc_observe_updates_v1 etc. This subscription can be destroyed by calling yunobserve function, which will cause to unsubscribe correlated callback.
Weak
YUndoManager

Unions§

YBranchIdVariant
YEventContent
YPathSegmentCase