Skip to main content

SystemStateSchema

Struct SystemStateSchema 

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

A validated, shareable SystemState layout.

SystemStateSchema owns an Arc to immutable metadata, making Clone a cheap reference-count increment. Every state derived from a specification shares the exact field order and name lookup table.

Implementations§

Source§

impl SystemStateSchema

Source

pub fn load_json_template(path: impl AsRef<Path>) -> Result<Self, StateError>

Loads and validates a state specification from a JSON template.

The file is read as bytes and parsed directly, avoiding an intermediate UTF-8 String allocation. The returned specification retains the input path for diagnostics and provenance but does not canonicalize it or keep the file open.

§Errors

Returns:

Source

pub fn create_empty_state(&self, time: SimulationTime) -> SystemState

Creates an empty SystemState that shares this specification.

Every declared field exists in the returned state’s layout, while every payload slot starts empty. Cloning the specification is constant-time and does not duplicate layout data.

Source

pub fn to_json_template(&self) -> Result<String, Error>

Converts this specification into a pretty-printed JSON template.

The generated document has the same strict fields structure accepted by SystemStateSchema::load_json_template. Runtime-only field indices and the source path are omitted: field indices are reconstructed from array order, and the destination path becomes the source when the JSON is loaded again.

Serialization borrows the immutable field slice and does not clone field names or descriptions. Absent descriptions are omitted.

§Errors

Returns the underlying serde_json::Error if JSON serialization fails.

Source

pub fn template_path(&self) -> &Path

Returns the path from which this specification was loaded.

The path is retained exactly as supplied to SystemStateSchema::load_json_template. It may be relative and is not guaranteed to remain accessible after loading.

Source

pub fn field_schemas(&self) -> &[StateFieldSchema]

Returns field definitions in deterministic template order.

Source

pub fn len(&self) -> usize

Returns the number of declared fields.

Source

pub fn is_empty(&self) -> bool

Reports whether the template declares no fields.

Empty templates are structurally valid and can represent time-bearing event records without scientific payloads.

Source

pub fn field_schema(&self, name: &str) -> Option<&StateFieldSchema>

Looks up a field definition by its normalized name.

Source

pub fn contains_field(&self, name: &str) -> bool

Reports whether the template declares name.

Trait Implementations§

Source§

impl Clone for SystemStateSchema

Source§

fn clone(&self) -> SystemStateSchema

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SystemStateSchema

Source§

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

Formats the value using the given formatter. Read more

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