pub struct Nucleo<T: Sync + Send + 'static> {
pub pattern: MultiPattern,
/* private fields */
}Expand description
A high level matcher worker that quickly computes matches in a background threadpool.
Fields§
§pattern: MultiPatternThe pattern matched by this matcher. To update the match pattern
MultiPattern::reparse should be used.
Note that the matcher worker will only become aware of the new pattern
after a call to tick.
Implementations§
Source§impl<T: Sync + Send + 'static> Nucleo<T>
impl<T: Sync + Send + 'static> Nucleo<T>
Sourcepub fn new(
config: Config,
notify: Arc<dyn Fn() + Sync + Send>,
num_threads: Option<usize>,
columns: u32,
) -> Self
pub fn new( config: Config, notify: Arc<dyn Fn() + Sync + Send>, num_threads: Option<usize>, columns: u32, ) -> Self
Constructs a new nucleo worker threadpool with the provided config.
notify is called everytime new information is available and
tick should be called. Note that notify is not
debounced, that should be handled by the downstream crate (for example
debouncing to only redraw at most every 1/60 seconds).
If None is passed for the number of worker threads, nucleo will use
one thread per hardware thread.
Nucleo can match items with multiple orthogonal properties. columns
indicates how many matching columns each item (and the pattern) has. The
number of columns cannot be changed after construction.
Sourcepub fn active_injectors(&self) -> usize
pub fn active_injectors(&self) -> usize
Returns the total number of active injectors
Sourcepub fn injector(&self) -> Injector<T>
pub fn injector(&self) -> Injector<T>
Returns an injector that can be used for adding candidates to the matcher.
Sourcepub fn restart(&mut self, clear_snapshot: bool)
pub fn restart(&mut self, clear_snapshot: bool)
Restart the the item stream. Removes all items and disconnects all
previously created injectors from this instance. If clear_snapshot
is true then all items and matched are removed from the Snapshot
immediately. Otherwise the snapshot will keep the current matches until
the matcher has run again.
§Note
The injectors will continue to function but they will not affect this instance anymore. The old items will only be dropped when all injectors were dropped.
Sourcepub fn update_config(&mut self, config: Config)
pub fn update_config(&mut self, config: Config)
Update the internal configuration.
pub fn sort_results(&mut self, sort_results: bool)
pub fn reverse_items(&mut self, reverse_items: bool)
Sourcepub fn tick(&mut self, timeout: u64) -> Status
pub fn tick(&mut self, timeout: u64) -> Status
The main way to interact with the matcher, this should be called
regularly (for example each time a frame is rendered). To avoid
excessive redraws this method will wait timeout milliseconds for the
worker thread to finish. It is recommend to set the timeout to 10ms.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Nucleo<T>
impl<T> !UnwindSafe for Nucleo<T>
impl<T> Freeze for Nucleo<T>
impl<T> Send for Nucleo<T>
impl<T> Sync for Nucleo<T>
impl<T> Unpin for Nucleo<T>
impl<T> UnsafeUnpin for Nucleo<T>
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> 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