pub struct PolicyEngine { /* private fields */ }Expand description
Evaluates actions against registered policies.
Implementations§
Source§impl PolicyEngine
impl PolicyEngine
pub fn new() -> PolicyEngine
pub fn register( &mut self, name: &str, check: Box<dyn Fn(&Action, &StateStore) -> Option<String> + Send + Sync>, description: &str, )
Sourcepub fn check(&self, action: &Action, state: &StateStore) -> Vec<PolicyViolation>
pub fn check(&self, action: &Action, state: &StateStore) -> Vec<PolicyViolation>
Check an action against all policies.
If a policy check panics, the panic is caught and treated as a violation.
pub fn policy_names(&self) -> Vec<String>
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Default for PolicyEngine
impl Default for PolicyEngine
Source§fn default() -> PolicyEngine
fn default() -> PolicyEngine
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PolicyEngine
impl !RefUnwindSafe for PolicyEngine
impl Send for PolicyEngine
impl Sync for PolicyEngine
impl Unpin for PolicyEngine
impl UnsafeUnpin for PolicyEngine
impl !UnwindSafe for PolicyEngine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more