Expose heads raw state representation#191
Conversation
3167492 to
5fa3988
Compare
c588e47 to
84896a2
Compare
heckj
left a comment
There was a problem hiding this comment.
Since the relevant methods are kind of hidden on Set<ChangeHash> and Data, I think it's worth adding something to the overall documentation for ChangeHash, or potentially Document.heads() to reference them - otherwise they'll be really hard to find for anyone searching for this functionality. Not critical for this PR though.
Co-authored-by: Joseph Heck <heckj@mac.com>
|
One thing that might be worth thinking about. In the |
|
Created #193 to extend this to expose, and use, the tryFrom logic in the Rust core library within the internal initializer for ChangeHash |
Motivation
Sometimes we want to persist in our domain a state representation based on
Set<ChangeHash>(aka heads) without coupling to the Automerge library. In this way, we can restore this state by moving back to the Automerge domain. It is usually quite interesting to implement an undo manager based on "commits".Introducing a
raw()method to retrieve the raw representation ofheadswithout any Automerge dependency; and also the go-back action intoSet<ChangeHash>.side-note: as we use an opaque type to encode the raw version of a group of change hashes, I am just checking it contains packages of 32 bytes to retrieve the associated change hash - after retrieving it, in case of not valid ChangeHash document will throw exceptions.