pub struct PatternManager { /* private fields */ }Expand description
Manager for before/after patterns.
On each poll of an expect operation, before patterns are checked before
the explicit patterns (highest priority), and after patterns are checked
after the explicit patterns fail to match (a fallback). This mirrors
Tcl expect’s expect_before/expect_after semantics; after patterns do
not run once an explicit pattern has matched.
Implementations§
Source§impl PatternManager
impl PatternManager
Sourcepub fn add_before(&mut self, pattern: PersistentPattern) -> String
pub fn add_before(&mut self, pattern: PersistentPattern) -> String
Add a before pattern and return its ID.
Sourcepub fn add_after(&mut self, pattern: PersistentPattern) -> String
pub fn add_after(&mut self, pattern: PersistentPattern) -> String
Add an after pattern and return its ID.
Sourcepub fn remove_before(&mut self, id: &str) -> Option<PersistentPattern>
pub fn remove_before(&mut self, id: &str) -> Option<PersistentPattern>
Remove a before pattern by ID.
Sourcepub fn remove_after(&mut self, id: &str) -> Option<PersistentPattern>
pub fn remove_after(&mut self, id: &str) -> Option<PersistentPattern>
Remove an after pattern by ID.
Sourcepub fn get_before(&self, id: &str) -> Option<&PersistentPattern>
pub fn get_before(&self, id: &str) -> Option<&PersistentPattern>
Get a before pattern by ID.
Sourcepub fn get_before_mut(&mut self, id: &str) -> Option<&mut PersistentPattern>
pub fn get_before_mut(&mut self, id: &str) -> Option<&mut PersistentPattern>
Get a mutable before pattern by ID.
Sourcepub fn get_after(&self, id: &str) -> Option<&PersistentPattern>
pub fn get_after(&self, id: &str) -> Option<&PersistentPattern>
Get an after pattern by ID.
Sourcepub fn get_after_mut(&mut self, id: &str) -> Option<&mut PersistentPattern>
pub fn get_after_mut(&mut self, id: &str) -> Option<&mut PersistentPattern>
Get a mutable after pattern by ID.
Sourcepub fn check_before(
&self,
buffer: &str,
) -> Option<(String, HandlerAction, Pattern)>
pub fn check_before( &self, buffer: &str, ) -> Option<(String, HandlerAction, Pattern)>
Check before patterns against the buffer.
Returns (id, action, matched_pattern) for the first matching pattern,
or None if none match. The matched pattern is returned so the caller
can consume the triggering match from its buffer (via Matcher) and
avoid re-firing on the next poll.
Sourcepub fn check_after(
&self,
buffer: &str,
) -> Option<(String, HandlerAction, Pattern)>
pub fn check_after( &self, buffer: &str, ) -> Option<(String, HandlerAction, Pattern)>
Check after patterns against the buffer.
Returns (id, action, matched_pattern) for the first matching pattern,
or None if none match. See Self::check_before for why the pattern
is returned.
Sourcepub fn before_pattern_set(&self) -> PatternSet
pub fn before_pattern_set(&self) -> PatternSet
Get all before patterns as a PatternSet for matching.
Sourcepub fn after_pattern_set(&self) -> PatternSet
pub fn after_pattern_set(&self) -> PatternSet
Get all after patterns as a PatternSet for matching.
Sourcepub fn clear_before(&mut self)
pub fn clear_before(&mut self)
Clear all before patterns.
Sourcepub fn clear_after(&mut self)
pub fn clear_after(&mut self)
Clear all after patterns.
Sourcepub fn before_count(&self) -> usize
pub fn before_count(&self) -> usize
Get the number of before patterns.
Sourcepub fn after_count(&self) -> usize
pub fn after_count(&self) -> usize
Get the number of after patterns.