pub struct TriggerMatcher { /* private fields */ }Expand description
Matcher for efficiently finding triggers by (entity_type, event_kind).
Uses a nested HashMap for O(1) lookup:
entity_type→event_kind→Vec<AfterMutationTrigger>- When
event_kindis None (matches all), stored separately for fallback
§Integration with FunctionObserver
When the FunctionObserver receives an EntityEvent from the mutation pipeline,
it calls find() to get all matching AfterMutationTriggers. For each matching
trigger, the observer spawns an async task to invoke the function without blocking
the mutation response. Task completion is tracked to prevent leaks on shutdown.
§Example
ⓘ
let mut matcher = TriggerMatcher::new();
matcher.add(AfterMutationTrigger {
function_name: "onUserCreated".to_string(),
entity_type: "User".to_string(),
event_filter: Some(EventKind::Insert),
});
// Later, when a User insert occurs:
let triggers = matcher.find("User", EventKind::Insert);
for trigger in triggers {
// Spawn async task to invoke function
}Implementations§
Source§impl TriggerMatcher
impl TriggerMatcher
Sourcepub fn add(&mut self, trigger: AfterMutationTrigger)
pub fn add(&mut self, trigger: AfterMutationTrigger)
Add a trigger to the matcher.
Trait Implementations§
Source§impl Clone for TriggerMatcher
impl Clone for TriggerMatcher
Source§fn clone(&self) -> TriggerMatcher
fn clone(&self) -> TriggerMatcher
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 moreSource§impl Debug for TriggerMatcher
impl Debug for TriggerMatcher
Auto Trait Implementations§
impl Freeze for TriggerMatcher
impl RefUnwindSafe for TriggerMatcher
impl Send for TriggerMatcher
impl Sync for TriggerMatcher
impl Unpin for TriggerMatcher
impl UnsafeUnpin for TriggerMatcher
impl UnwindSafe for TriggerMatcher
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