pub struct Policy { /* private fields */ }Expand description
Execution policy containing rules for command authorization.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn add_prefix_rule(
&mut self,
pattern: &[String],
decision: Decision,
) -> Result<(), Error>
pub fn add_prefix_rule( &mut self, pattern: &[String], decision: Decision, ) -> Result<(), Error>
Add a prefix rule to the policy.
§Errors
Returns an error for a zero-token pattern without changing the policy.
Sourcepub fn rules(&self) -> &[PrefixRule]
pub fn rules(&self) -> &[PrefixRule]
The prefix rules in evaluation order (first match wins).
Sourcepub fn prepend_layer(&mut self, rules: impl IntoIterator<Item = PrefixRule>)
pub fn prepend_layer(&mut self, rules: impl IntoIterator<Item = PrefixRule>)
Prepend a higher-precedence layer of rules.
Used when merging rule-file layers (workspace rules over user rules):
a pattern that already exists — either in this policy or earlier within
rules — keeps its first occurrence, so the highest-precedence layer
wins and evaluation order (check) stays deterministic.
Sourcepub fn check(&self, command: &[String]) -> RuleMatch
pub fn check(&self, command: &[String]) -> RuleMatch
Check a single command against the policy.
Sourcepub fn check_multiple<I, F>(
&self,
commands: I,
heuristics_fallback: &F,
) -> PolicyEvaluation
pub fn check_multiple<I, F>( &self, commands: I, heuristics_fallback: &F, ) -> PolicyEvaluation
Check multiple commands against the policy, accepting borrowed slices as well as references to command vectors without copying arguments.
Sourcepub fn prefix_rules(&self) -> &[PrefixRule]
pub fn prefix_rules(&self) -> &[PrefixRule]
Get all prefix rules.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Policy
impl Freeze for Policy
impl Move for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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<T> CacheValue for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> 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