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 e3 75 69 08 e5 b5 b9 be b4 31 1e c2 59 9b 82 a4 07 02
# Restore cursor later
restored <- am_cursor_from_bytes(bytes, text_obj)
am_cursor_position(restored) # 5
#> [1] 5
am_close(doc)