aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/sealed.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-29 03:21:43 +0000
committertv <tv@krebsco.de>2026-11-29 03:21:43 +0000
commite63d30c2581033a85489b10c3f5b252fdbb5049e (patch)
tree5f4e6f65f1cecfb32f841e7ad7d9d106aeb69b20 /src/access/sealed.rs
parent9188fa6e13ea7facfab5fb6f55bf26444ec2c01e (diff)
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).
Diffstat (limited to 'src/access/sealed.rs')
-rw-r--r--src/access/sealed.rs12
1 files changed, 8 insertions, 4 deletions
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<Declared> {
+pub(crate) fn declared(doc: &(impl Read + ?Sized)) -> Vec<Declared> {
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<BTreeSet<String>, 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.<age file>)".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<String>,