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>
impl<'a> StateProjection<'a>
Sourcepub fn required(
&mut self,
key: impl Into<Rc<str>>,
value: &'a mut Array,
) -> Result<(), StateProjectionError>
pub fn required( &mut self, key: impl Into<Rc<str>>, value: &'a mut Array, ) -> Result<(), StateProjectionError>
Declare a required keyed slot.
Sourcepub fn optional(
&mut self,
key: impl Into<Rc<str>>,
value: &'a mut Option<Array>,
) -> Result<(), StateProjectionError>
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.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of declared slots, including absent optional slots.
Sourcepub fn present_len(&self) -> usize
pub fn present_len(&self) -> usize
Return the number of currently present arrays.
Sourcepub fn values(&self) -> impl Iterator<Item = &Array>
pub fn values(&self) -> impl Iterator<Item = &Array>
Traverse present arrays in stable key order.
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut Array> + use<'_, 'a>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut Array> + use<'_, 'a>
Traverse present arrays mutably in stable key order.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, Option<&Array>)>
pub fn iter(&self) -> impl Iterator<Item = (&str, Option<&Array>)>
Traverse every key and optional-presence tag in stable key order.
Sourcepub fn iter_mut(
&mut self,
) -> impl Iterator<Item = (&str, Option<&mut Array>)> + use<'_, 'a>
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.
Sourcepub fn into_entries(self) -> impl Iterator<Item = (Rc<str>, &'a Array)>
pub fn into_entries(self) -> impl Iterator<Item = (Rc<str>, &'a Array)>
Consume the projection into present immutable entries in stable key order.
Sourcepub fn into_entries_mut(self) -> impl Iterator<Item = (Rc<str>, &'a mut Array)>
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.
Sourcepub fn snapshot(&self) -> StateSnapshot
pub fn snapshot(&self) -> StateSnapshot
Capture every declared key and optional-presence tag.
Sourcepub fn layout(&self) -> Vec<StateLayoutEntry>
pub fn layout(&self) -> Vec<StateLayoutEntry>
Derive the key, presence, dtype, and shape layout.
Sourcepub fn restore(
&mut self,
snapshot: StateSnapshot,
reset_new: bool,
) -> Result<(), StateProjectionError>
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>
impl<'a> Debug for StateProjection<'a>
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Option.