pub struct DestructiveDetector { /* private fields */ }Expand description
Detects destructive commands using glob pattern matching.
Patterns are built from the configured safety preset plus any custom patterns from the user’s config file.
Implementations§
Source§impl DestructiveDetector
impl DestructiveDetector
Sourcepub fn new(config: &SafetyConfig) -> Self
pub fn new(config: &SafetyConfig) -> Self
Create a new detector from safety configuration.
Builds patterns from the preset level and appends any custom patterns.
Sourcepub fn is_destructive(&self, command: &str) -> bool
pub fn is_destructive(&self, command: &str) -> bool
Check if a command matches any destructive pattern.
The command is normalized before matching to prevent bypass tricks like double spaces or backslash escapes.
Sourcepub fn match_reason(&self, command: &str) -> Option<String>
pub fn match_reason(&self, command: &str) -> Option<String>
Return a human-readable reason if the command is destructive.
The command is normalized before matching to prevent bypass tricks like double spaces or backslash escapes.
Auto Trait Implementations§
impl Freeze for DestructiveDetector
impl RefUnwindSafe for DestructiveDetector
impl Send for DestructiveDetector
impl Sync for DestructiveDetector
impl Unpin for DestructiveDetector
impl UnwindSafe for DestructiveDetector
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