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: Render + SSS> Worker<Indexed<T>>
impl<T: Render + SSS> Worker<Indexed<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.
Examples found in repository?
More examples
examples/basic.rs (line 8)
5async fn main() -> Result<()> {
6 let items = vec!["item1", "item2", "item3"];
7
8 let worker = Worker::new_single_column();
9 worker.append(items);
10 let selector = Selector::new(Indexed::identifier);
11 let mm = Matchmaker::new(worker, selector);
12
13 match mm.pick_default().await {
14 Ok(v) => {
15 println!("{}", v[0]);
16 }
17 Err(err) => match err {
18 MatchError::Abort(1) => {
19 eprintln!("cancelled");
20 }
21 _ => {
22 eprintln!("Error: {err}");
23 }
24 },
25 }
26
27 Ok(())
28}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. Note that it is clearly unsound to use this concurrently with other workers, or to subsequently push with an IndexedInjector.
Examples found in repository?
More examples
examples/basic.rs (line 9)
5async fn main() -> Result<()> {
6 let items = vec!["item1", "item2", "item3"];
7
8 let worker = Worker::new_single_column();
9 worker.append(items);
10 let selector = Selector::new(Indexed::identifier);
11 let mm = Matchmaker::new(worker, selector);
12
13 match mm.pick_default().await {
14 Ok(v) => {
15 println!("{}", v[0]);
16 }
17 Err(err) => match err {
18 MatchError::Abort(1) => {
19 eprintln!("cancelled");
20 }
21 _ => {
22 eprintln!("Error: {err}");
23 }
24 },
25 }
26
27 Ok(())
28}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 as displayed in the picker correspond to indices according to the relative order of the column names given to this function.
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 shutdown(&mut self)
pub fn restart(&mut self, clear_snapshot: bool)
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 + '_
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> !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> MaybeExt for T
impl<T> MaybeExt for T
Source§fn maybe_take(&mut self, maybe: Option<T>)
fn maybe_take(&mut self, maybe: Option<T>)
Merge from maybe by taking.
Source§fn maybe_clone(&mut self, maybe: &Option<T>)where
T: Clone,
fn maybe_clone(&mut self, maybe: &Option<T>)where
T: Clone,
Merge from maybe by cloning.