pub struct Chunk<I, T> { /* private fields */ }Expand description
Chunk of items.
This data type represents a collection of items that are grouped together
for processing. Unlike Delta, a Chunk contains items that are all
present (i.e., not optional). Chunks are used to process a batch of items
as a single unit, e.g., for windowing or pagination.
Note that chunks are assumed to always only contain unique items, meaning there are no two items with the same identifier in a chunk. This invariant must be checked with unit tests (which we provide for our operators), but is not enforced at runtime for performance reasons.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Chunk;
// Create chunk of items
let chunk = Chunk::from([
Item::new("a", 1),
Item::new("b", 2),
Item::new("c", 3),
]);Implementations§
Source§impl<I, T> Chunk<I, T>
impl<I, T> Chunk<I, T>
Sourcepub fn iter(&self) -> Iter<'_, Item<I, T>>
pub fn iter(&self) -> Iter<'_, Item<I, T>>
Creates an iterator over the chunk of items.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Chunk;
// Create chunk of items
let chunk = Chunk::from([
Item::new("a", 1),
Item::new("b", 2),
Item::new("c", 3),
]);
// Create iterator over items
for item in chunk.iter() {
println!("{item:?}");
}Trait Implementations§
Source§impl<I, T, U> FromIterator<U> for Chunk<I, T>
impl<I, T, U> FromIterator<U> for Chunk<I, T>
Source§fn from_iter<V>(iter: V) -> Selfwhere
V: IntoIterator<Item = U>,
fn from_iter<V>(iter: V) -> Selfwhere
V: IntoIterator<Item = U>,
Creates a chunk of items from an iterator.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Chunk;
// Create chunk of items
let chunk = Chunk::from_iter([
Item::new("a", 1),
Item::new("b", 2),
Item::new("c", 3),
]);Source§impl<'a, I, T> IntoIterator for &'a Chunk<I, T>
impl<'a, I, T> IntoIterator for &'a Chunk<I, T>
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Creates an iterator over the chunk of items.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Chunk;
// Create chunk of items
let chunk = Chunk::from([
Item::new("a", 1),
Item::new("b", 2),
Item::new("c", 3),
]);
// Create iterator over items
for item in &chunk {
println!("{item:?}");
}Source§impl<I, T> IntoIterator for Chunk<I, T>
impl<I, T> IntoIterator for Chunk<I, T>
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Creates an iterator over the chunk of items.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Chunk;
// Create chunk of items
let chunk = Chunk::from([
Item::new("a", 1),
Item::new("b", 2),
Item::new("c", 3),
]);
// Create iterator over items
for item in chunk.iter() {
println!("{item:?}");
}impl<I: Eq, T: Eq> Eq for Chunk<I, T>
impl<I, T> StructuralPartialEq for Chunk<I, T>
impl<I, T> Value for Chunk<I, T>
Auto Trait Implementations§
impl<I, T> Freeze for Chunk<I, T>
impl<I, T> RefUnwindSafe for Chunk<I, T>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<I, T> Send for Chunk<I, T>
impl<I, T> Sync for Chunk<I, T>
impl<I, T> Unpin for Chunk<I, T>
impl<I, T> UnwindSafe for Chunk<I, T>where
I: UnwindSafe,
T: UnwindSafe,
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> IntoReport<T> for Twhere
T: Value,
impl<T> IntoReport<T> for Twhere
T: Value,
Source§impl<T, E> IntoReport<T, E> for Twhere
E: Error,
impl<T, E> IntoReport<T, E> for Twhere
E: Error,
Source§fn into_report(self) -> Result<Report<T>, E>
fn into_report(self) -> Result<Report<T>, E>
Creates a report from a value T and wraps it in a result.
§Examples
use std::io::Error;
use zrx_diagnostic::report::IntoReport;
// Define function returning a value
fn f() -> impl IntoReport<i32, Error> {
42
}
// Invoke function and create report
let res = f().into_report();