Chunk

Struct Chunk 

Source
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>

Source

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: Clone, T: Clone> Clone for Chunk<I, T>

Source§

fn clone(&self) -> Chunk<I, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug, T: Debug> Debug for Chunk<I, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I, T> Default for Chunk<I, T>

Source§

fn default() -> Self

Creates an empty chunk of items.

§Examples
use zrx_stream::value::Chunk;

// Create empty chunk of items
let chunk = Chunk::default();
Source§

impl<I, T, U, const N: usize> From<[U; N]> for Chunk<I, T>
where U: Into<Item<I, T>>,

Source§

fn from(value: [U; N]) -> Self

Creates a chunk of items from a slice 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),
]);
Source§

impl<I, T, U> FromIterator<U> for Chunk<I, T>
where U: Into<Item<I, T>>,

Source§

fn from_iter<V>(iter: V) -> Self
where 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>

Source§

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§

type Item = &'a Item<I, T>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Item<I, T>>

Which kind of iterator are we turning this into?
Source§

impl<I, T> IntoIterator for Chunk<I, T>

Source§

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:?}");
}
Source§

type Item = Item<I, T>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<Chunk<I, T> as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

impl<I: PartialEq, T: PartialEq> PartialEq for Chunk<I, T>

Source§

fn eq(&self, other: &Chunk<I, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: Eq, T: Eq> Eq for Chunk<I, T>

Source§

impl<I, T> StructuralPartialEq for Chunk<I, T>

Source§

impl<I, T> Value for Chunk<I, T>
where I: Id, T: Value,

Auto Trait Implementations§

§

impl<I, T> Freeze for Chunk<I, T>

§

impl<I, T> RefUnwindSafe for Chunk<I, T>

§

impl<I, T> Send for Chunk<I, T>
where I: Send, T: Send,

§

impl<I, T> Sync for Chunk<I, T>
where I: Sync, T: Sync,

§

impl<I, T> Unpin for Chunk<I, T>
where I: Unpin, T: Unpin,

§

impl<I, T> UnwindSafe for Chunk<I, T>
where I: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoReport<T> for T
where T: Value,

Source§

fn into_report(self) -> Result<Report<T>, Error>

Creates a report from a value T and wraps it in a result.

Source§

impl<T, E> IntoReport<T, E> for T
where E: Error,

Source§

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();
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ValueExt for T
where T: Value,

Source§

fn with_diagnostics<D>(self, diagnostics: D) -> Report<Self>

Adds diagnostics to the value. Read more
Source§

impl<K, V, T> StoreFromIterator<K, V> for T
where T: FromIterator<(K, V)>,