diff options
Diffstat (limited to 'src/state/host.rs')
| -rw-r--r-- | src/state/host.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/state/host.rs b/src/state/host.rs index 7c3e165..30ebcdb 100644 --- a/src/state/host.rs +++ b/src/state/host.rs @@ -226,6 +226,19 @@ impl Host for AppState { async move { state.mutate_doc(f).await } } + fn refuse_writes(&self, copy: bool) -> impl Future<Output = Option<Document>> + Send { + let state = self.clone(); + async move { + tokio::task::spawn_blocking(move || { + let mut replica = state.doc.blocking_write(); + replica.writable = false; + copy.then(|| replica.doc.clone()) + }) + .await + .expect("document write task panicked") + } + } + fn accept_writes(&self) -> impl Future<Output = ()> + Send { let state = self.clone(); async move { |
