pub struct RiskClassifier { /* private fields */ }Expand description
Classifies an Action into the minimum PermissionTier required
to perform it. Combines a built-in heuristic with optional custom
rules; the result is the highest tier any signal implies, since
risk is monotonic (one high-risk signal escalates the whole action).
Implementations§
Source§impl RiskClassifier
impl RiskClassifier
Sourcepub fn new() -> RiskClassifier
pub fn new() -> RiskClassifier
A classifier with only the built-in heuristic.
Sourcepub fn add_rule<F>(&mut self, name: &str, tier: PermissionTier, matcher: F)
pub fn add_rule<F>(&mut self, name: &str, tier: PermissionTier, matcher: F)
Add a custom rule. A matching rule can only raise the required
tier (via max), never lower it — safety is the default.
Sourcepub fn classify(&self, action: &Action) -> PermissionTier
pub fn classify(&self, action: &Action) -> PermissionTier
Classify an action into its minimum required tier.
Sourcepub fn classify_with_haystack(
&self,
action: &Action,
haystack: Option<&str>,
) -> PermissionTier
pub fn classify_with_haystack( &self, action: &Action, haystack: Option<&str>, ) -> PermissionTier
RiskClassifier::classify reusing a haystack the caller already
built. A caller computing both axes for one action would otherwise
flatten and lowercase the whole parameter payload twice — see
classify_reversibility_with_haystack, and action_text for the
haystack itself.
Trait Implementations§
Source§impl Debug for RiskClassifier
impl Debug for RiskClassifier
Source§impl Default for RiskClassifier
impl Default for RiskClassifier
Source§fn default() -> RiskClassifier
fn default() -> RiskClassifier
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for RiskClassifier
impl !UnwindSafe for RiskClassifier
impl Freeze for RiskClassifier
impl Send for RiskClassifier
impl Sync for RiskClassifier
impl Unpin for RiskClassifier
impl UnsafeUnpin for RiskClassifier
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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