Skip to content

Converts an am_change object back to its serialized raw vector form.

Usage

am_change_to_bytes(change)

Arguments

change

An am_change object (from am_get_changes() or am_change_from_bytes())

Value

A raw vector containing the serialized change

Examples

doc <- am_create()
am_put(doc, AM_ROOT, "key", "value")
am_commit(doc, "Add key")

history <- am_get_changes(doc)
bytes <- am_change_to_bytes(history[[1]])
bytes
#>  [1] 85 6f 4a 83 64 09 0d 49 01 3c 00 10 9c 88 73 cd b8 31 17 3c 2b 38
#> [23] 2e 72 68 d9 57 1a 01 01 00 07 41 64 64 20 6b 65 79 00 06 15 05 34
#> [45] 01 42 02 56 02 57 05 70 02 7f 03 6b 65 79 01 7f 01 7f 56 76 61 6c
#> [67] 75 65 7f 00

# Round-trip
restored <- am_change_from_bytes(bytes)
identical(am_change_to_bytes(restored), bytes)  # TRUE
#> [1] TRUE

am_close(doc)