Converts a cursor to a raw vector representation that can be persisted
and later restored with am_cursor_from_bytes(). This enables saving
cursor positions across R sessions.
Arguments
- cursor
An
am_cursorobject created byam_cursor()
Examples
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)
bytes
#> [1] 01 03 10 95 05 5a 2a c1 88 e3 9c b5 2f 31 ee 09 8f eb be 07 02
# Restore cursor later
restored <- am_cursor_from_bytes(bytes, text_obj)
am_cursor_position(restored) # 5
#> [1] 5
am_close(doc)