From 9188fa6e13ea7facfab5fb6f55bf26444ec2c01e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 03:15:05 +0000 Subject: document: values read and written through a view any kind of document gives document::view: Read (the value at a path, plain, typed, a map's keys) and Write (a value written, one deleted), which Automerge's documents, writes in progress and documents as they were all are. The member registry, the users, access control's reads and rules, the topology, forgetting and bootstrap read and write through them, and name neither Automerge's ReadDoc and Transactable nor document::store, which is what an Automerge document can do beyond. How a swarm holding a store judges what a change writes is handed to the rules (rules::judge_seen), being its kind of document's to say. --- src/access/strict.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/access/strict.rs') diff --git a/src/access/strict.rs b/src/access/strict.rs index 0b294f8..9857bed 100644 --- a/src/access/strict.rs +++ b/src/access/strict.rs @@ -16,7 +16,7 @@ use serde_json::Value as JsonValue; use sha2::{Digest, Sha256}; use super::{envelope, sshsig}; -use crate::document::{ReadDoc, store}; +use crate::document::view::{self, Read}; /// What a manifest's signature is for (`sshsig`). pub(crate) const NAMESPACE: &str = "continuum-strict"; @@ -95,21 +95,21 @@ pub(crate) fn digest(value: &JsonValue) -> String { /// The places values are signed in `doc` (`envelope::signed_paths`, `*` as `doc` has /// them) that hold one, with it, as the store reads it. -pub(crate) fn held(doc: &impl ReadDoc) -> Vec<(Vec, JsonValue)> { +pub(crate) fn held(doc: &impl Read) -> Vec<(Vec, JsonValue)> { fn expand( - doc: &impl ReadDoc, + doc: &impl Read, pattern: &[String], at: Vec, out: &mut Vec<(Vec, JsonValue)>, ) { match pattern.split_first() { None => { - if let Ok(Some(value)) = store::read_path(doc, &at) { + if let Ok(Some(value)) = view::read_path(doc, &at) { out.push((at, value)); } } Some((segment, rest)) if segment == "*" => { - for key in store::keys_at(doc, &at).ok().flatten().unwrap_or_default() { + for key in view::keys_at(doc, &at).ok().flatten().unwrap_or_default() { let mut next = at.clone(); next.push(key); expand(doc, rest, next, out); @@ -135,7 +135,7 @@ pub(crate) fn held(doc: &impl ReadDoc) -> Vec<(Vec, JsonValue)> { /// held at a signed place now, the policy `policy`, for `user` to look over and sign at /// `at`. Its exact line. pub(crate) fn manifest_of( - doc: &impl ReadDoc, + doc: &impl Read, swarm: &str, epoch: crate::document::replica::EpochRecord, base: &[crate::document::ChangeHash], @@ -225,15 +225,15 @@ mod tests { fn a_manifest_signed_and_checked() { let mut doc = Document::new(); change(&mut doc, |doc| { - store::write_path(doc, &path("_continuum/users/alice"), &json!({"caps": {}})).unwrap(); - store::write_path( + view::write_path(doc, &path("_continuum/users/alice"), &json!({"caps": {}})).unwrap(); + view::write_path( doc, &path("_continuum/access/userSigned"), &json!([["config"]]), ) .unwrap(); - store::write_path(doc, &path("config"), &json!({"mode": "fast"})).unwrap(); - store::write_path(doc, &path("notes"), &json!(1)).unwrap(); + view::write_path(doc, &path("config"), &json!({"mode": "fast"})).unwrap(); + view::write_path(doc, &path("notes"), &json!(1)).unwrap(); }); let policy = json!({"version": 1, "values": "signed"}); let epoch = -- cgit v1.3.1