Learn R Programming

automerge (version 0.3.0)

am_change_from_bytes: Parse a serialized change from raw bytes

Description

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.

Usage

am_change_from_bytes(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().

Arguments

bytes

A raw vector containing a serialized change (from am_change_to_bytes())

Details

Note: am_get_changes(), 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

Run this code
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
am_change_message(change)  # "Add key"

am_close(doc)

Run the code above in your browser using DataLab