aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
Diffstat (limited to 'src/document')
-rw-r--r--src/document/changes.rs4
-rw-r--r--src/document/inspect.rs11
2 files changed, 14 insertions, 1 deletions
diff --git a/src/document/changes.rs b/src/document/changes.rs
index eef7dbc..44d30bd 100644
--- a/src/document/changes.rs
+++ b/src/document/changes.rs
@@ -156,7 +156,9 @@ pub(crate) fn delta_bytes(
Some(bytes)
}
-/// Loads a delta (`delta_bytes`) into `doc`.
+/// Loads a delta (`delta_bytes`) into `doc`, unjudged: for tests; a node screens what it
+/// downloads (`access::screen::apply_bytes`).
+#[cfg(test)]
pub(crate) fn load_delta(doc: &mut Document, bytes: &[u8]) -> Result<()> {
if let Some(misplaced) = misplaced_author(bytes) {
bail!("Refused the downloaded changes: {misplaced}");
diff --git a/src/document/inspect.rs b/src/document/inspect.rs
index c42de82..f0356de 100644
--- a/src/document/inspect.rs
+++ b/src/document/inspect.rs
@@ -86,6 +86,17 @@ impl Place {
}
}
+/// Whether any of `changes` does anything at a map key `key`: a cheap look, without
+/// placing anything, for whether they may write the policy (`access::screen`).
+pub(crate) fn touch_key(changes: &[ExpandedChange], key: &str) -> bool {
+ changes.iter().any(|change| {
+ change
+ .operations
+ .iter()
+ .any(|op| matches!(&op.key, Key::Map(name) if name.as_str() == key))
+ })
+}
+
/// Where a write at `path` in `doc` is, as rules see it (`Inspector`): placed by the
/// same rule (`Place::child`), so cut after the first list or text on the way, which
/// what is inside one touches. Where `doc` holds nothing (or a scalar) on the way, the