pub struct Worker<T>where
T: SSS,{ /* private fields */ }Expand description
Worker: can instantiate, push, and get results. A view into computation.
Additionally, the worker can affect the computation via find and restart.
Implementations§
Source§impl<T: SSS> Worker<Indexed<T>>
impl<T: SSS> Worker<Indexed<T>>
Sourcepub fn append(&self, items: impl IntoIterator<Item = T>) -> u32
pub fn append(&self, items: impl IntoIterator<Item = T>) -> u32
A convenience method to initialize data. Items are indexed starting from the current nucleo item count.
§Notes
- Not concurrent.
- Subsequent use of IndexedInjector should start from the returned count.
Source§impl<T: Render + SSS> Worker<T>
impl<T: Render + SSS> Worker<T>
Sourcepub fn new_single_column() -> Self
pub fn new_single_column() -> Self
Create a new worker over items which are displayed in the picker as exactly their as_str representation.
Source§impl<T> Worker<T>where
T: ColumnIndexable + SSS,
impl<T> Worker<T>where
T: ColumnIndexable + SSS,
Sourcepub fn new_indexable<I, S>(column_names: I) -> Self
pub fn new_indexable<I, S>(column_names: I) -> Self
Create a new worker over indexable items, whose columns correspond to indices according to the relative order of the column names given to this function.
§Example
#[derive(Clone)]
pub struct RunAction {
name: String,
alias: String,
desc: String
};
use matchmaker::{Matchmaker, Selector};
use matchmaker::nucleo::{Indexed, Worker, ColumnIndexable};
impl ColumnIndexable for RunAction {
fn get_str(&self, i: usize) -> std::borrow::Cow<'_, str> {
if i == 0 {
&self.name
} else if i == 1 {
&self.alias
} else {
&self.desc
}.into()
}
}
pub fn make_mm(
items: impl Iterator<Item = RunAction>,
) -> Matchmaker<Indexed<RunAction>, RunAction> {
let worker = Worker::new_indexable(["name", "alias", "desc"]);
worker.append(items);
let selector = Selector::new(Indexed::identifier);
Matchmaker::new(worker, selector)
}Source§impl<T> Worker<T>where
T: SSS,
impl<T> Worker<T>where
T: SSS,
Sourcepub fn new(
columns: impl IntoIterator<Item = Column<T>>,
default_column: usize,
) -> Self
pub fn new( columns: impl IntoIterator<Item = Column<T>>, default_column: usize, ) -> Self
Column names must be distinct!
pub fn injector(&self) -> WorkerInjector<T>
pub fn find(&mut self, line: &str)
pub fn get_nth(&self, n: u32) -> Option<&T>
pub fn new_snapshot(nucleo: &mut Nucleo<T>) -> (&Snapshot<T>, Status)
pub fn raw_results( &self, ) -> impl ExactSizeIterator<Item = &T> + DoubleEndedIterator + '_
pub fn restart(&mut self, clear_snapshot: bool)
Source§impl<T: SSS> Worker<T>
impl<T: SSS> Worker<T>
Sourcepub fn results(
&mut self,
start: u32,
end: u32,
width_limits: &[u16],
highlight_style: Style,
matcher: &mut Matcher,
) -> (WorkerResults<'_, T>, Vec<u16>, Status)
pub fn results( &mut self, start: u32, end: u32, width_limits: &[u16], highlight_style: Style, matcher: &mut Matcher, ) -> (WorkerResults<'_, T>, Vec<u16>, Status)
§Notes
- width is at least header width
pub fn exact_column_match(&mut self, column: &str) -> Option<&T>
pub fn format_with<'a>(&'a self, item: &'a T, col: &str) -> Option<Cow<'a, str>>
Auto Trait Implementations§
impl<T> Freeze for Worker<T>
impl<T> !RefUnwindSafe for Worker<T>
impl<T> Send for Worker<T>
impl<T> Sync for Worker<T>
impl<T> Unpin for Worker<T>
impl<T> UnsafeUnpin for Worker<T>
impl<T> !UnwindSafe for Worker<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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> TransformExt for T
impl<T> TransformExt for T
fn transform<Q>(self, transform: impl FnOnce(T) -> Q) -> Q
fn modify<Q>(self, modify: impl FnOnce(&mut T) -> Q) -> T
Source§fn modify_if<Q>(self, condition: bool, modify: impl FnOnce(&mut T) -> Q) -> T
fn modify_if<Q>(self, condition: bool, modify: impl FnOnce(&mut T) -> Q) -> T
Example Read more