pub struct Delta<I, T> { /* private fields */ }Expand description
Delta of items.
This data type represents a collection of items that can include insertions
and deletions (if Option is None), which we call deltas. Deltas are
the means of differentially passing changes through a stream. They must be
applied to a store to manifest the changes they represent.
Note that deltas are assumed to always only contain unique items, meaning there are no two items with the same identifier in a delta. This invariant must be checked with unit tests (which we provide for our operators), but is not enforced at runtime for performance reasons. Differential semantics still hold if this invariant is violated, but performance might be impacted due to unnecessary re-computations.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Delta;
// Create delta of items
let delta = Delta::from([
Item::new("a", Some(1)),
Item::new("b", Some(2)),
Item::new("c", Some(3)),
]);Implementations§
Source§impl<I, T> Delta<I, T>
impl<I, T> Delta<I, T>
Sourcepub fn iter(&self) -> Iter<'_, Item<I, Option<T>>>
pub fn iter(&self) -> Iter<'_, Item<I, Option<T>>>
Creates an iterator over the delta of items.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Delta;
// Create delta of items
let delta = Delta::from([
Item::new("a", Some(1)),
Item::new("b", Some(2)),
Item::new("c", Some(3)),
]);
// Create iterator over items
for item in delta.iter() {
println!("{item:?}");
}Trait Implementations§
Source§impl<I, T, U> FromIterator<U> for Delta<I, T>
impl<I, T, U> FromIterator<U> for Delta<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 delta of items from an iterator.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Delta;
// Create delta of items
let delta = Delta::from_iter([
Item::new("a", Some(1)),
Item::new("b", Some(2)),
Item::new("c", Some(3)),
]);Source§impl<'a, I, T> IntoIterator for &'a Delta<I, T>
impl<'a, I, T> IntoIterator for &'a Delta<I, T>
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Creates an iterator over the delta of items.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Delta;
// Create delta of items
let delta = Delta::from([
Item::new("a", Some(1)),
Item::new("b", Some(2)),
Item::new("c", Some(3)),
]);
// Create iterator over items
for item in &delta {
println!("{item:?}");
}Source§impl<I, T> IntoIterator for Delta<I, T>
impl<I, T> IntoIterator for Delta<I, T>
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Creates an iterator over the delta of items.
§Examples
use zrx_scheduler::effect::Item;
use zrx_stream::value::Delta;
// Create delta of items
let delta = Delta::from([
Item::new("a", Some(1)),
Item::new("b", Some(2)),
Item::new("c", Some(3)),
]);
// Create iterator over items
for item in delta {
println!("{item:?}");
}impl<I, T> Value for Delta<I, T>
Auto Trait Implementations§
impl<I, T> Freeze for Delta<I, T>
impl<I, T> RefUnwindSafe for Delta<I, T>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<I, T> Send for Delta<I, T>
impl<I, T> Sync for Delta<I, T>
impl<I, T> Unpin for Delta<I, T>
impl<I, T> UnwindSafe for Delta<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();