pub struct UserTrigger {
pub name: String,
pub pattern: Option<Regex>,
pub agents: Vec<String>,
pub commands: Vec<String>,
}Expand description
A compiled, validated user trigger ready for matching.
Constructed from UserTriggerConfig via UserTrigger::validate.
Regex is Clone (cheap, internally Arc), so cloning a UserTrigger
is cheap; the regex’s compiled state is shared rather than re-compiled.
Fields§
§name: String§pattern: Option<Regex>§agents: Vec<String>§commands: Vec<String>Implementations§
Source§impl UserTrigger
impl UserTrigger
Sourcepub fn validate(cfg: &UserTriggerConfig) -> Result<Self>
pub fn validate(cfg: &UserTriggerConfig) -> Result<Self>
Validate and compile a UserTriggerConfig into a UserTrigger.
Returns KlaspError::ConfigParse if:
- Both
patternandcommandsare absent/empty (at least one required). patternis present but is not a valid regex.
Sourcepub fn matches(&self, cmd: &str, agent: &str) -> bool
pub fn matches(&self, cmd: &str, agent: &str) -> bool
Returns true if this trigger matches cmd for the given agent.
Matching logic:
- If
agentsis non-empty,agentmust be listed. - If
patternis set, it is tested against the fullcmd. - If
commandsis non-empty,cmdis tested for an exact match.
A pattern or commands match is sufficient — they are OR’d.
Trait Implementations§
Source§impl Clone for UserTrigger
impl Clone for UserTrigger
Source§fn clone(&self) -> UserTrigger
fn clone(&self) -> UserTrigger
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UserTrigger
impl RefUnwindSafe for UserTrigger
impl Send for UserTrigger
impl Sync for UserTrigger
impl Unpin for UserTrigger
impl UnsafeUnpin for UserTrigger
impl UnwindSafe for UserTrigger
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