pub struct MicroscopeMatcher { /* private fields */ }Expand description
Streaming fuzzy matcher using Nucleo
Provides non-blocking fuzzy matching with progressive results.
Items are injected via Injector and results are retrieved via snapshot().
§Example
let matcher = MicroscopeMatcher::new();
// Get injector for background task
let injector = matcher.injector();
tokio::spawn(async move {
for item in items {
injector.push(MatcherItem::new(item), |mi, cols| {
cols[0] = mi.match_text.clone();
});
}
});
// In render loop
matcher.tick(10); // Process for max 10ms
let results = matcher.get_matched_items(100); // Get top 100 resultsImplementations§
Source§impl MicroscopeMatcher
impl MicroscopeMatcher
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new streaming matcher
Uses smart case matching and Unicode normalization. Spawns worker threads for parallel matching.
Sourcepub fn injector(&self) -> Injector<MatcherItem>
pub fn injector(&self) -> Injector<MatcherItem>
Get an injector for pushing items from background tasks
The injector is thread-safe and can be cloned and sent to other threads.
Sourcepub fn set_pattern(&mut self, query: &str)
pub fn set_pattern(&mut self, query: &str)
Update the search pattern
This triggers re-matching of all items against the new pattern.
Sourcepub fn tick(&mut self, timeout_ms: u64) -> MatcherStatus
pub fn tick(&mut self, timeout_ms: u64) -> MatcherStatus
Process pending matches (non-blocking)
Call this regularly (e.g., in render loop) to process matches. Returns status indicating if more processing is needed.
§Arguments
timeout_ms- Maximum time to spend processing (in milliseconds)
Sourcepub fn get_matched_items(&self, max_items: usize) -> Vec<MicroscopeItem>
pub fn get_matched_items(&self, max_items: usize) -> Vec<MicroscopeItem>
Get matched items from the current snapshot
Returns items sorted by match score (best matches first). This is instant and does not block.
Note: The items are pre-sorted by nucleo, so the order reflects the ranking. Individual scores are not exposed by nucleo’s streaming API, so we use the item index as a rough score proxy (lower = better match).
§Arguments
max_items- Maximum number of items to return
Sourcepub fn total_count(&self) -> u32
pub fn total_count(&self) -> u32
Get total number of items in the matcher
Sourcepub fn matched_count(&self) -> u32
pub fn matched_count(&self) -> u32
Get number of items matching the current pattern
Sourcepub fn is_pattern_empty(&self) -> bool
pub fn is_pattern_empty(&self) -> bool
Check if pattern is empty (all items match)
Sourcepub fn restart(&mut self)
pub fn restart(&mut self)
Restart the matcher (clear all items)
Call this when switching pickers or starting a new search.
Sourcepub fn restart_with_clear(&mut self)
pub fn restart_with_clear(&mut self)
Restart and also clear the pattern
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MicroscopeMatcher
impl !RefUnwindSafe for MicroscopeMatcher
impl Send for MicroscopeMatcher
impl Sync for MicroscopeMatcher
impl Unpin for MicroscopeMatcher
impl !UnwindSafe for MicroscopeMatcher
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more