pub struct LockLazyQuery<'a, T: 'static, L, I>{ /* private fields */ }Expand description
Lazy query for locked data with early termination.
Implementations§
Source§impl<'a, T: 'static, L, I> LockLazyQuery<'a, T, L, I>
impl<'a, T: 'static, L, I> LockLazyQuery<'a, T, L, I>
Sourcepub fn where_<F, P>(
self,
path: KeyPaths<T, F>,
predicate: P,
) -> LockLazyQuery<'a, T, L, impl Iterator<Item = &'a L> + 'a>
pub fn where_<F, P>( self, path: KeyPaths<T, F>, predicate: P, ) -> LockLazyQuery<'a, T, L, impl Iterator<Item = &'a L> + 'a>
Filter using a key-path predicate (lazy).
Sourcepub fn select_lazy<F>(
self,
path: KeyPaths<T, F>,
) -> impl Iterator<Item = F> + 'awhere
F: Clone + 'static,
pub fn select_lazy<F>(
self,
path: KeyPaths<T, F>,
) -> impl Iterator<Item = F> + 'awhere
F: Clone + 'static,
Map to a field value (lazy).
This allows you to select only specific fields from locked data without cloning the entire object. Perfect for projecting data efficiently.
§Example
ⓘ
// Select only product names (not full objects)
let names: Vec<String> = products
.lock_lazy_query()
.where_(Product::price_r(), |&p| p > 100.0)
.select_lazy(Product::name_r())
.collect();
// Select only IDs
let ids: Vec<u32> = products
.lock_lazy_query()
.where_(Product::stock_r(), |&s| s > 0)
.select_lazy(Product::id_r())
.take(10)
.collect();
// Select prices and compute sum
let total: f64 = products
.lock_lazy_query()
.where_(Product::category_r(), |c| c == "Electronics")
.select_lazy(Product::price_r())
.sum();Performance Note: This is much more efficient than collecting full objects and then extracting fields, as it only clones the specific field value.
Sourcepub fn take_lazy(self, n: usize) -> impl Iterator<Item = T> + 'awhere
T: Clone,
pub fn take_lazy(self, n: usize) -> impl Iterator<Item = T> + 'awhere
T: Clone,
Take first N items (lazy).
Auto Trait Implementations§
impl<'a, T, L, I> Freeze for LockLazyQuery<'a, T, L, I>where
I: Freeze,
impl<'a, T, L, I> RefUnwindSafe for LockLazyQuery<'a, T, L, I>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, L, I> Send for LockLazyQuery<'a, T, L, I>
impl<'a, T, L, I> Sync for LockLazyQuery<'a, T, L, I>
impl<'a, T, L, I> Unpin for LockLazyQuery<'a, T, L, I>where
I: Unpin,
impl<'a, T, L, I> UnwindSafe for LockLazyQuery<'a, T, L, I>where
I: UnwindSafe,
T: RefUnwindSafe,
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