Delta

Struct Delta 

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

Source

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

Source§

fn clone(&self) -> Delta<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 Delta<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 Delta<I, T>

Source§

fn default() -> Self

Creates an empty delta of items.

§Examples
use zrx_stream::value::Delta;

// Create empty delta of items
let delta = Delta::default();
Source§

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

Source§

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

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

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

Source§

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

Source§

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§

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

The type of the elements being iterated over.
Source§

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

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

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

Source§

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§

type Item = Item<I, Option<T>>

The type of the elements being iterated over.
Source§

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

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

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<I, T> UnwindSafe for Delta<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)>,