coqui_access_acl/condition.rs
1//! Conditions on entries, decided by the consumer.
2
3use coqui_access::Person;
4
5/// What a condition comes to for one request.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum Truth {
8 /// It holds: the entry applies.
9 True,
10 /// It does not: the entry does not apply.
11 False,
12 /// It cannot be told: an allow entry is skipped and a deny entry applies, as Windows
13 /// treats conditional ACEs.
14 Unknown,
15}
16
17/// Decides an entry's [`condition`](crate::Entry::condition), in whatever language the
18/// consumer writes them in: a NetBox-style constraint checked against its database, a
19/// Windows conditional expression, a time window.
20///
21/// With no `Conditions` given, or nobody signed in, every condition is [`Truth::Unknown`].
22pub trait Conditions: Send + Sync {
23 /// What `condition`, on an entry of `item`'s ACL, comes to for `person`.
24 fn holds(&self, condition: &str, item: &str, person: &Person) -> Truth;
25}