aboutsummaryrefslogtreecommitdiffstats
path: root/src/state/host.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 19:29:26 +0100
committertv <tv@krebsco.de>2026-11-01 19:29:26 +0100
commit2ac2b0e2b08f14be07c46b3fd9a516a64e9933fb (patch)
treeab47737eca775947374850f31d7b4670dcbb6ddb /src/state/host.rs
parentbb2fdddc91bf9c1e8e11dc5408b0dddb95300a49 (diff)
LWW everywhere, mostly
Diffstat (limited to 'src/state/host.rs')
-rw-r--r--src/state/host.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/state/host.rs b/src/state/host.rs
index 30ebcdb..eb7db35 100644
--- a/src/state/host.rs
+++ b/src/state/host.rs
@@ -226,6 +226,35 @@ impl Host for AppState {
async move { state.mutate_doc(f).await }
}
+ fn superseded(&self) -> crate::remake::Superseded {
+ self.superseded_writes
+ }
+
+ fn commit_changes<T, F>(&self, f: F) -> impl Future<Output = Result<T, StoreError>> + Send
+ where
+ F: FnOnce(&mut Document) -> T + Send + 'static,
+ T: Send + 'static,
+ {
+ let state = self.clone();
+ async move {
+ tokio::task::spawn_blocking(move || {
+ let result = {
+ let mut replica = state.doc.blocking_write();
+ if !replica.writable {
+ return Err(StoreError::Rejoining);
+ }
+ let result = f(&mut replica.doc);
+ replica.refresh_heads();
+ result
+ };
+ state.publish_change();
+ Ok(result)
+ })
+ .await
+ .expect("document write task panicked")
+ }
+ }
+
fn refuse_writes(&self, copy: bool) -> impl Future<Output = Option<Document>> + Send {
let state = self.clone();
async move {