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: &Path) -> Result<Self, StateError>
pub fn load_json_template(path: &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: StateTime) -> SystemState
pub fn create_empty_state(&self, time: StateTime) -> 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§impl SystemStateSchema
impl SystemStateSchema
Reports whether two schema handles share one immutable allocation.
This is an identity comparison, not structural equality. Independently loaded but textually identical schemas do not share an instance.
Sourcepub fn template_path(&self) -> &Path
pub fn template_path(&self) -> &Path
Returns the path from which this schema was loaded.
Sourcepub fn field_schemas(&self) -> &[StateFieldSchema]
pub fn field_schemas(&self) -> &[StateFieldSchema]
Returns field descriptions in deterministic template order.
Sourcepub fn field_schema(&self, name: &str) -> Option<&StateFieldSchema>
pub fn field_schema(&self, name: &str) -> Option<&StateFieldSchema>
Looks up one field description by normalized name.
Sourcepub fn contains_field(&self, name: &str) -> bool
pub fn contains_field(&self, name: &str) -> bool
Reports whether the schema declares name.
Sourcepub fn to_json_template(&self) -> Result<String, Error>
pub fn to_json_template(&self) -> Result<String, Error>
Converts this schema to the strict, pretty-printed JSON template format.
Trait Implementations§
Source§impl Clone for SystemStateSchema
impl Clone for SystemStateSchema
Auto Trait Implementations§
impl Freeze for SystemStateSchema
impl RefUnwindSafe for SystemStateSchema
impl Send for SystemStateSchema
impl Sync for SystemStateSchema
impl Unpin for SystemStateSchema
impl UnsafeUnpin for SystemStateSchema
impl UnwindSafe for SystemStateSchema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more