diff options
| author | tv <tv@krebsco.de> | 2026-10-31 19:53:27 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 19:53:27 +0100 |
| commit | 6105507200231e67ba544c12aa10b988e1c23826 (patch) | |
| tree | 880530b7401cb5d43f52e06a68b4d704326aa272 /src/document/file.rs | |
| parent | 8d7adfbdb7798cca9d9783761f290e3bd85d9a3a (diff) | |
use Automerge as Document instead of AutoCommit
This allows a lot of operations to drop mut.
Diffstat (limited to 'src/document/file.rs')
| -rw-r--r-- | src/document/file.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/document/file.rs b/src/document/file.rs index 6439e27..9efae42 100644 --- a/src/document/file.rs +++ b/src/document/file.rs @@ -20,8 +20,8 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, MutexGuard}; use std::time::Duration; +use super::{ActorId, ChangeHash, Document}; use anyhow::{Context, Result, anyhow, bail}; -use automerge::{ActorId, AutoCommit, ChangeHash}; use serde::{Deserialize, Serialize}; use tokio::time::Instant; use tracing::{debug, error, warn}; @@ -42,7 +42,7 @@ struct Header { /// A document file as read at start. pub(crate) struct Loaded { /// Under a fresh actor. - pub(crate) doc: AutoCommit, + pub(crate) doc: Document, /// The actors this node wrote with before. pub(crate) actors: Vec<ActorId>, } @@ -88,7 +88,7 @@ fn parse(bytes: &[u8]) -> Result<(Loaded, usize)> { .collect::<Result<Vec<_>>>()?; let mut records = &rest[line_end + 1..]; - let mut doc: Option<AutoCommit> = None; + let mut doc: Option<Document> = None; while !records.is_empty() { let Some((length, after)) = records.split_first_chunk::<4>() else { break; @@ -226,7 +226,7 @@ impl DocumentFile { pub(crate) async fn rewrite( self: &Arc<Self>, epoch: Epoch, - mut copy: AutoCommit, + copy: Document, own: Vec<ActorId>, reason: &str, ) { @@ -247,7 +247,7 @@ impl DocumentFile { .into_iter() .filter(|actor| *actor == current || present.contains(actor)) .collect(); - let save = super::save(&mut copy); + let save = super::save(©); let bytes = whole(&actors, &save)?; writer .files @@ -327,7 +327,7 @@ mod tests { #[test] fn whole_then_increments() { - let mut doc = AutoCommit::new(); + let mut doc = Document::new(); change(&mut doc, |doc| doc.put(ROOT, "a", 1_i64).unwrap()); let actor = doc.get_actor().clone(); let heads = doc.get_heads(); |
