Deserializes a change from raw bytes into an am_change object. This is
useful for restoring changes that were previously serialized with
am_change_to_bytes() or saved to disk.
Arguments
- bytes
A raw vector containing a serialized change (from
am_change_to_bytes())
Value
An am_change object (external pointer) that can be passed to
am_change_hash(), am_change_message(), am_change_time(),
am_change_actor_id(), am_change_seq(), and am_change_deps().
Details
Note: am_get_changes() and other change-returning functions already return
am_change objects directly, so this function is only needed when working
with raw byte representations.
Examples
doc <- am_create()
am_put(doc, AM_ROOT, "key", "value")
am_commit(doc, "Add key")
# Serialize a change and restore it
history <- am_get_changes(doc)
bytes <- am_change_to_bytes(history[[1]])
change <- am_change_from_bytes(bytes)
change
#> <Automerge Change>
#> Hash: 5d 87 5a 9a ...
#> Message: Add key
am_change_message(change) # "Add key"
#> [1] "Add key"
am_close(doc)