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
impl SystemStateSchema
Sourcepub fn load_json_template(path: impl AsRef<Path>) -> Result<Self, StateError>
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:
StateError::TemplateReadwhen the file cannot be read;StateError::TemplateParsewhen JSON syntax or structure is invalid;StateError::EmptyFieldNamefor an empty normalized field name;StateError::DuplicateFieldfor repeated normalized names.
Sourcepub fn create_empty_state(&self, time: SimulationTime) -> SystemState
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.
Sourcepub fn to_json_template(&self) -> Result<String, Error>
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.
Sourcepub fn template_path(&self) -> &Path
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.
Sourcepub fn field_schemas(&self) -> &[StateFieldSchema]
pub fn field_schemas(&self) -> &[StateFieldSchema]
Returns field definitions in deterministic template order.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn field_schema(&self, name: &str) -> Option<&StateFieldSchema>
pub fn field_schema(&self, name: &str) -> Option<&StateFieldSchema>
Looks up a field definition by its normalized name.
Sourcepub fn contains_field(&self, name: &str) -> bool
pub fn contains_field(&self, name: &str) -> bool
Reports whether the template declares name.
Trait Implementations§
Source§impl Clone for SystemStateSchema
impl Clone for SystemStateSchema
Source§fn clone(&self) -> SystemStateSchema
fn clone(&self) -> SystemStateSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more