Learn R Programming

automerge (version 0.3.0)

am_cursor_from_bytes: Restore a cursor from bytes

Description

Restores a cursor from a raw vector previously created by am_cursor_to_bytes(). The text object is required to associate the cursor with a document.

Usage

am_cursor_from_bytes(bytes, obj)

Value

An am_cursor object

Arguments

bytes

A raw vector containing a serialized cursor

obj

An Automerge text object to associate the cursor with

See Also

am_cursor_to_bytes()

Examples

Run this code
doc <- am_create()
am_put(doc, AM_ROOT, "text", am_text("Hello World"))
text_obj <- am_get(doc, AM_ROOT, "text")

cursor <- am_cursor(text_obj, 5)
bytes <- am_cursor_to_bytes(cursor)

restored <- am_cursor_from_bytes(bytes, text_obj)
restored
am_cursor_position(restored)  # 5

am_close(doc)

Run the code above in your browser using DataLab