Skip to main content

StateProjection

Struct StateProjection 

Source
pub struct StateProjection<'a> { /* private fields */ }
Expand description

A stable, keyed declaration of mutable array state.

Required and optional slots are declared once. All derived views use the same sorted keys and preserve whether every optional slot is present.

Implementations§

Source§

impl<'a> StateProjection<'a>

Source

pub fn new() -> Self

Create an empty projection.

Source

pub fn required( &mut self, key: impl Into<Rc<str>>, value: &'a mut Array, ) -> Result<(), StateProjectionError>

Declare a required keyed slot.

Source

pub fn optional( &mut self, key: impl Into<Rc<str>>, value: &'a mut Option<Array>, ) -> Result<(), StateProjectionError>

Declare an optional keyed slot, retaining its key when the value is absent.

Source

pub fn len(&self) -> usize

Return the number of declared slots, including absent optional slots.

Source

pub fn is_empty(&self) -> bool

Return whether no slots are declared.

Source

pub fn present_len(&self) -> usize

Return the number of currently present arrays.

Source

pub fn values(&self) -> impl Iterator<Item = &Array>

Traverse present arrays in stable key order.

Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut Array> + use<'_, 'a>

Traverse present arrays mutably in stable key order.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, Option<&Array>)>

Traverse every key and optional-presence tag in stable key order.

Source

pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (&str, Option<&mut Array>)> + use<'_, 'a>

Traverse every key and mutable optional-presence tag in stable key order.

Source

pub fn into_entries(self) -> impl Iterator<Item = (Rc<str>, &'a Array)>

Consume the projection into present immutable entries in stable key order.

Source

pub fn into_entries_mut(self) -> impl Iterator<Item = (Rc<str>, &'a mut Array)>

Consume the projection into present mutable entries in stable key order.

Source

pub fn snapshot(&self) -> StateSnapshot

Capture every declared key and optional-presence tag.

Source

pub fn layout(&self) -> Vec<StateLayoutEntry>

Derive the key, presence, dtype, and shape layout.

Source

pub fn restore( &mut self, snapshot: StateSnapshot, reset_new: bool, ) -> Result<(), StateProjectionError>

Restore a keyed snapshot.

When reset_new is true, slots created after the snapshot are retained and zeroed. All other keys and optional-presence tags are restored exactly.

Trait Implementations§

Source§

impl<'a> Debug for StateProjection<'a>

Source§

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

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

impl Default for StateProjection<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !Send for StateProjection<'a>

§

impl<'a> !Sync for StateProjection<'a>

§

impl<'a> !UnwindSafe for StateProjection<'a>

§

impl<'a> Freeze for StateProjection<'a>

§

impl<'a> RefUnwindSafe for StateProjection<'a>

§

impl<'a> Unpin for StateProjection<'a>

§

impl<'a> UnsafeUnpin for StateProjection<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoOption<T> for T

Source§

fn into_option(self) -> Option<T>

Convert into an Option.
Source§

impl<T> IntoStrideBy for T

Source§

fn stride_by(self, stride: i32) -> StrideBy<T>

Create a stride indexing operation.
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.