struct WriteIndex {
by_collection: HashMap<String, CollectionTrie>,
any_collection: CollectionTrie,
}Expand description
The write-subject index: collection, then changed path, then action.
Fields§
§by_collection: HashMap<String, CollectionTrie>Policies declared for a specific set of collections.
any_collection: CollectionTriePolicies declared with Scope::Any collections — checked for every
write regardless of its collection.
Implementations§
Source§impl WriteIndex
impl WriteIndex
fn insert( &mut self, policy: PolicyId, collections: &Scope<String>, kinds: KindSet, actions: ActionSet, path_prefixes: &Scope<String>, )
Sourcefn candidates(
&self,
collection: &str,
kind: SubjectKind<'_>,
action: WriteAction,
changes: &[Change<'_>],
) -> Vec<PolicyId>
fn candidates( &self, collection: &str, kind: SubjectKind<'_>, action: WriteAction, changes: &[Change<'_>], ) -> Vec<PolicyId>
A write matching no policy costs exactly this: at most two hash
lookups (the specific collection, the Scope::Any bucket) and,
only when one of those exists, a walk bounded by the write’s own
changed paths — never by the number of policies registered.
changes carries before/after values (see Change); this index
only ever reads change.path out of it — routing is on where a
write touched, not on what it changed to. A value predicate belongs
in the evaluator that a matched policy names, with the full
Change and Subject available to it.