Skip to main content

WriteIndex

Struct WriteIndex 

Source
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: CollectionTrie

Policies declared with Scope::Any collections — checked for every write regardless of its collection.

Implementations§

Source§

impl WriteIndex

Source

fn insert( &mut self, policy: PolicyId, collections: &Scope<String>, kinds: KindSet, actions: ActionSet, path_prefixes: &Scope<String>, )

Source

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.

Trait Implementations§

Source§

impl Debug for WriteIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WriteIndex

Source§

fn default() -> WriteIndex

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.