pub struct MockMatch {
pub tool: Option<String>,
pub contains: Option<String>,
pub pattern: Option<String>,
pub input: BTreeMap<String, FieldPredicate>,
}Expand description
What a mock/spy declaration matches on. At least one criterion is required; every given criterion must hold (AND).
Fields§
§tool: Option<String>Case-insensitive exact match on the tool name. Tool names are
per-harness (Bash on claude-code, bash on opencode/crush), so
cross-harness matchers usually prefer contains/pattern/input.
contains: Option<String>Substring match over the raw hook event JSON (the tool name and its input always serialize into it). Note the haystack is JSON: quotes and backslashes inside tool input appear escaped.
pattern: Option<String>Unanchored regex over the same haystack as contains, for non-exact
needles like git push( --force)?. Linear-time engine (no lookarounds).
input: BTreeMap<String, FieldPredicate>Per-field predicates on the tool’s input: the key is the argument name
(command, file_path, …), and every listed field must match (a field
absent from the call fails the matcher). Non-string fields are compared
against their compact JSON form.
Implementations§
Source§impl MockMatch
impl MockMatch
Sourcepub fn matches_call(&self, tool: Option<&str>, input: Option<&Value>) -> bool
pub fn matches_call(&self, tool: Option<&str>, input: Option<&Value>) -> bool
Whether this matcher covers a call with tool name and input args.
The contains/pattern haystack is the synthesized compact event JSON
({"tool_name":…,"tool_input":…}), mirroring what the hook-side rules
match against.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MockMatch
impl<'de> Deserialize<'de> for MockMatch
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for MockMatch
impl StructuralPartialEq for MockMatch
Auto Trait Implementations§
impl Freeze for MockMatch
impl RefUnwindSafe for MockMatch
impl Send for MockMatch
impl Sync for MockMatch
impl Unpin for MockMatch
impl UnsafeUnpin for MockMatch
impl UnwindSafe for MockMatch
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.