pub struct Injector<T> { /* private fields */ }Expand description
A handle that allows adding new items to a Nucleo worker.
It’s internally reference counted and can be cheaply cloned and sent across threads.
Implementations§
Source§impl<T> Injector<T>
impl<T> Injector<T>
Sourcepub fn push(
&self,
value: T,
fill_columns: impl FnOnce(&T, &mut [Utf32String]),
) -> u32
pub fn push( &self, value: T, fill_columns: impl FnOnce(&T, &mut [Utf32String]), ) -> u32
Appends an element to the list of matched items. This function is lock-free and wait-free.
Sourcepub fn extend<I>(
&self,
values: I,
fill_columns: impl Fn(&T, &mut [Utf32String]),
)where
I: IntoIterator<Item = T> + ExactSizeIterator,
pub fn extend<I>(
&self,
values: I,
fill_columns: impl Fn(&T, &mut [Utf32String]),
)where
I: IntoIterator<Item = T> + ExactSizeIterator,
Appends multiple elements to the list of matched items. This function is lock-free and wait-free.
You should favor this function over push if at least one of the following is true:
- the number of items you’re adding can be computed beforehand and is typically larger than 1k
- you’re able to batch incoming items
- you’re adding items from multiple threads concurrently (this function results in less contention)
Sourcepub fn injected_items(&self) -> u32
pub fn injected_items(&self) -> u32
Returns the total number of items injected in the matcher. This might not match the number of items in the match snapshot (if the matcher is still running)
Sourcepub unsafe fn get_unchecked(&self, index: u32) -> Item<'_, T>
pub unsafe fn get_unchecked(&self, index: u32) -> Item<'_, T>
Returns a reference to the item at the given index.
§Safety
Item at index must be initialized. That means you must have observed
push returning this value or get returning Some for this value.
Just because a later index is initialized doesn’t mean that this index
is initialized
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Injector<T>
impl<T> !UnwindSafe for Injector<T>
impl<T> Freeze for Injector<T>
impl<T> Send for Injector<T>
impl<T> Sync for Injector<T>
impl<T> Unpin for Injector<T>
impl<T> UnsafeUnpin for Injector<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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