From 9c12bf2e8815dc9b42be62f1e1fd2932dd02938b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 19:53:27 +0100 Subject: use Automerge as Document instead of AutoCommit This allows a lot of operations to drop mut. --- src/document/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/document/mod.rs') diff --git a/src/document/mod.rs b/src/document/mod.rs index 9633241..fa1fa77 100644 --- a/src/document/mod.rs +++ b/src/document/mod.rs @@ -2,21 +2,23 @@ //! (merged-view paths over JSON) the HTTP API and remakes work with. /// The engine's types, under the names the rest of the crate uses: the document -/// (Automerge's `AutoCommit`), its changes and their hashes, and its writers (actors); -/// and what can be written like a document (`Transactable`). +/// (Automerge's `Automerge`), its changes and their hashes, and its writers (actors); +/// a write to it (`Transaction`: one change, committed or dropped whole), and what can +/// be read like a document (`ReadDoc`: the document, or a write in progress) and written +/// like one (`Transactable`). /// Only `document` and `remake` use Automerge itself (`architecture.md`, The document). -pub(crate) use automerge::transaction::Transactable; -pub(crate) use automerge::{ActorId, AutoCommit as Document, Change, ChangeHash}; +pub(crate) use automerge::transaction::{Transactable, Transaction}; +pub(crate) use automerge::{ActorId, Automerge as Document, Change, ChangeHash, ReadDoc}; /// The whole document as bytes, as the engine saves it: a backup, the document /// file's full save, the size a joining node downloads. -pub(crate) fn save(doc: &mut Document) -> Vec { +pub(crate) fn save(doc: &Document) -> Vec { doc.save() } /// The changes after `since` as bytes that, appended to a save, load with it (the /// document file's appends). -pub(crate) fn save_since(doc: &mut Document, since: &[ChangeHash]) -> Vec { +pub(crate) fn save_since(doc: &Document, since: &[ChangeHash]) -> Vec { doc.save_after(since) } -- cgit v1.3.1