From e63d30c2581033a85489b10c3f5b252fdbb5049e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 03:21:43 +0000 Subject: state: plain writes take a view to write, Automerge's are asked for as such AppState::mutate_doc, mutate_doc_registering and mutate_doc_by hand what they are given a document::view::Write: the member registry, the users, sessions, forgetting and bootstrap write through them, and take whatever kind of document gives it. AppState::mutate_doc_for is for what asks more of an Automerge document than values at paths (the store's API, a remake's host, a store's events), and gives the heads after the write. What reads a view takes one of any size (dyn Write among them). --- src/access/sealed.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/access/sealed.rs') diff --git a/src/access/sealed.rs b/src/access/sealed.rs index c30bea7..b39a465 100644 --- a/src/access/sealed.rs +++ b/src/access/sealed.rs @@ -48,7 +48,7 @@ pub(crate) struct Declared { } /// What `doc` declares sealed; an entry that doesn't read as one is left out. -pub(crate) fn declared(doc: &impl Read) -> Vec { +pub(crate) fn declared(doc: &(impl Read + ?Sized)) -> Vec { let Ok(Some(JsonValue::Array(entries))) = view::read_plain(doc, &declared_at()) else { return Vec::new(); }; @@ -141,7 +141,11 @@ pub(crate) fn recipients(sealed: &str) -> Result, String> { /// (as its writer saw it): a sealed value, or, signed by its user (`access::envelope`), /// one holding a sealed value or `null` (deleted); with readers declared, sealed for /// exactly their keys. -pub(crate) fn check(doc: &impl Read, declared: &Declared, value: &JsonValue) -> Result<(), String> { +pub(crate) fn check( + doc: &(impl Read + ?Sized), + declared: &Declared, + value: &JsonValue, +) -> Result<(), String> { let JsonValue::String(text) = value else { return Err("a sealed value is a string (cs1.)".to_owned()); }; @@ -184,7 +188,7 @@ pub(crate) fn check(doc: &impl Read, declared: &Declared, value: &JsonValue) -> /// Checks what is at `path` in `doc` after a write there: nothing within a declared /// place but its value, and every value at one (at `path` or below it) as `check` says. /// Why not, if not. -pub(crate) fn kept(doc: &impl Read, path: &[String]) -> Result<(), String> { +pub(crate) fn kept(doc: &(impl Read + ?Sized), path: &[String]) -> Result<(), String> { let declared = declared(doc); if declared.is_empty() || !reaches(&declared, path) { return Ok(()); @@ -193,7 +197,7 @@ pub(crate) fn kept(doc: &impl Read, path: &[String]) -> Result<(), String> { return Err(format!("/{} is within a sealed value", path.join("/"))); } fn walk( - doc: &impl Read, + doc: &(impl Read + ?Sized), declared: &[Declared], value: &JsonValue, at: &mut Vec, -- cgit v1.3.1