Skip to main content

StateSeries

Struct StateSeries 

Source
pub struct StateSeries { /* private fields */ }
Expand description

A growable homogeneous array of owned, time-ordered system states.

spec remains present even when the collection is empty, so later appends can be checked with constant-time layout identity. Each stored state carries its own cheap handle to the same immutable layout allocation and therefore remains independently valid after removal from the series.

Implementations§

Source§

impl StateSeries

Source

pub fn new(spec: SystemStateSchema) -> Self

Creates an empty series with no state capacity reserved.

This stores the supplied specification handle but allocates no state or payload storage. Use StateSeries::with_capacity when an analysis or reader already knows an approximate state count.

Source

pub fn with_capacity(spec: SystemStateSchema, capacity: usize) -> Self

Creates an empty series with capacity for at least capacity states.

The reservation covers only SystemState owners in the backing vector. It does not create states, duplicate the shared layout, or allocate any scientific payload.

Source

pub fn schema(&self) -> &SystemStateSchema

Returns the canonical immutable specification for this collection.

Source

pub fn as_view(&self) -> StateSeriesView<'_>

Creates a copyable read-only view over the complete collection.

The view contains only borrowed references to the canonical specification and state slice. Constructing, copying, or cloning it never clones a state, layout, payload, or vector allocation.

Source

pub fn len(&self) -> usize

Returns the number of states currently owned by the collection.

Source

pub fn is_empty(&self) -> bool

Reports whether the collection currently owns no states.

Source

pub fn capacity(&self) -> usize

Returns the backing vector’s current state-owner capacity.

Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more state owners.

Existing states and their payload allocations remain logically unchanged. As with Vec::reserve, the allocator may reserve more than the exact requested amount.

Source

pub fn state_at(&self, position: usize) -> Option<&SystemState>

Returns one immutable state by zero-based collection position.

This follows slice conventions and returns None when position is outside the collection. The position is distinct from the state’s iteration because sampled iterations may contain gaps.

Source

pub fn payload_mut_at<T>( &mut self, position: usize, key: &str, ) -> Result<&mut T, StateSeriesError>
where T: Any,

Mutably borrows one typed payload in one stored state.

This is the collection’s only mutable analysis boundary. It delegates concrete type validation to SystemState::payload_mut but does not expose the containing SystemState; callers therefore cannot change its time, clear unrelated fields, or replace it with a foreign layout.

Only one payload can be borrowed mutably at a time under ordinary Rust borrowing rules. Applications requiring coupled mutation should group the coupled values into one payload type.

§Errors

Returns StateSeriesError::PositionOutOfBounds when no state exists at position. An unknown key, empty field, or concrete type mismatch is returned as StateSeriesError::PayloadAccess with the original crate::system_state::StateError preserved as its source.

Source

pub fn first_state(&self) -> Option<&SystemState>

Returns the earliest stored state, or None when the series is empty.

Source

pub fn last_state(&self) -> Option<&SystemState>

Returns the latest stored state, or None when the series is empty.

Source

pub fn as_state_slice(&self) -> &[SystemState]

Returns every state as one immutable contiguous slice.

No mutable slice is exposed because element replacement could bypass both shared-layout validation and increasing-iteration validation.

Source

pub fn iter(&self) -> Iter<'_, SystemState>

Returns an iterator over immutable states in increasing iteration order.

Source

pub fn push_state( &mut self, state: SystemState, ) -> Result<(), StateSeriesPushError>

Appends one owned state after validating collection invariants.

Success moves state directly into the backing vector without cloning it or any payload. Failure returns StateSeriesPushError containing the complete unchanged state, allowing the caller to recover expensive data without cloning before the operation.

§Errors
Source

pub fn pop_state(&mut self) -> Option<SystemState>

Removes and returns the latest state without cloning its payloads.

A later append is compared with the new final state. Once empty, the series accepts any iteration from a state sharing its layout.

Source

pub fn clear_states(&mut self)

Drops every state while retaining specification and vector capacity.

Stored payloads are dropped with their owning states. This method is an explicit analysis working-set operation and has no relationship to writer rollover or persistent chunks.

Source

pub fn into_states(self) -> Vec<SystemState>

Consumes the series and returns its complete state vector.

The vector allocation, states, and payload allocations move unchanged. Dropping the separate canonical specification handle is safe because every returned state retains its own shared handle.

Trait Implementations§

Source§

impl Clone for StateSeries

Source§

fn clone(&self) -> Self

Creates a fully independent deep copy of all states and payloads.

§Performance warning

Cost scales with the complete populated payload volume and may involve gigabytes of allocation and copying. This method is appropriate only when analysis requires independent mutable payload ownership. Use StateSeries::as_view or an Arc<StateSeries> for lightweight sharing. The immutable specification allocation remains shared.

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StateSeries

Source§

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

Formats bounded structural context without traversing payload values.

Source§

impl<'a> IntoIterator for &'a StateSeries

Source§

fn into_iter(self) -> Self::IntoIter

Iterates over borrowed states without exposing mutable replacement.

Source§

type Item = &'a SystemState

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, SystemState>

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

impl IntoIterator for StateSeries

Source§

fn into_iter(self) -> Self::IntoIter

Consumes the series and moves each owned state out in iteration order.

Source§

type Item = SystemState

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<SystemState>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
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.