pub struct PolicyTreeBuilder {
evaluators: Vec<Arc<dyn Evaluator>>,
declarations: Vec<PolicyDeclaration>,
}Expand description
Builds a PolicyTree from a set of evaluators and the policies that
use them.
Fields§
§evaluators: Vec<Arc<dyn Evaluator>>§declarations: Vec<PolicyDeclaration>Implementations§
Source§impl PolicyTreeBuilder
impl PolicyTreeBuilder
Sourcepub fn register_evaluator(
&mut self,
evaluator: Arc<dyn Evaluator>,
) -> EvaluatorId
pub fn register_evaluator( &mut self, evaluator: Arc<dyn Evaluator>, ) -> EvaluatorId
Register an evaluator, returning the id later policies reference. One evaluator may serve many policies.
Sourcepub fn add_policy(&mut self, declaration: PolicyDeclaration) -> PolicyId
pub fn add_policy(&mut self, declaration: PolicyDeclaration) -> PolicyId
Add a policy, returning its PolicyId. Policies are assigned ids
in the order they are added here, which becomes the tree’s
presentational evaluation order.
Panics if declaration.predicate names an evaluator id that was not
returned by register_evaluator on
this builder — a programmer error in the caller wiring up the tree,
not a runtime condition.
Predicate::Unusable needs no
such check: it names no evaluator to have registered.
Sourcepub fn build(self) -> PolicyTree
pub fn build(self) -> PolicyTree
Build the tree.
Trait Implementations§
Source§impl Default for PolicyTreeBuilder
impl Default for PolicyTreeBuilder
Source§fn default() -> PolicyTreeBuilder
fn default() -> PolicyTreeBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PolicyTreeBuilder
impl !RefUnwindSafe for PolicyTreeBuilder
impl Send for PolicyTreeBuilder
impl Sync for PolicyTreeBuilder
impl Unpin for PolicyTreeBuilder
impl UnsafeUnpin for PolicyTreeBuilder
impl !UnwindSafe for PolicyTreeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more