diff options
Diffstat (limited to 'src/access')
| -rw-r--r-- | src/access/policy.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/access/policy.rs b/src/access/policy.rs index 9f18eb5..97bea27 100644 --- a/src/access/policy.rs +++ b/src/access/policy.rs @@ -88,11 +88,15 @@ pub(crate) fn first( /// The policy `doc` holds. pub(crate) fn of(doc: &impl ReadDoc) -> Policy { - let value = match store::read_plain(doc, &path()) { - Ok(Some(value)) => value, - Ok(None) => return Policy::Open, - Err(error) => return Policy::Unknown(format!("it doesn't read: {error}")), - }; + match store::read_plain(doc, &path()) { + Ok(Some(value)) => read(&value), + Ok(None) => Policy::Open, + Err(error) => Policy::Unknown(format!("it doesn't read: {error}")), + } +} + +/// The policy `value`, as the policy's place holds it, says. +pub(crate) fn read(value: &JsonValue) -> Policy { let version = value.get("version").and_then(JsonValue::as_u64); if version != Some(VERSION) { return Policy::Unknown(format!( |
