Skip to main content

SystemStateWriterBuilder

Struct SystemStateWriterBuilder 

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

Builder for one exclusive state-recording directory.

The builder owns only paths, immutable configuration, and a cheap shared SystemStateSchema handle. It opens no files and starts no threads before SystemStateWriterBuilder::create_new_recording, SystemStateWriterBuilder::continue_existing_recording, or SystemStateWriterBuilder::continue_recording_from_latest_checkpoint.

Implementations§

Source§

impl SystemStateWriterBuilder

Source

pub fn new(root: impl Into<PathBuf>, spec: &SystemStateSchema) -> Self

Creates an empty run configuration using TimeAxisMetadata::default.

spec is cloned only as an Arc-backed metadata handle. No scientific state or payload exists in this builder.

Source

pub fn with_time_axis_metadata(self, time: TimeAxisMetadata) -> Self

Replaces the run’s temporal-coordinate documentation.

Source

pub fn with_user_metadata(self, metadata: Map<String, Value>) -> Self

Merges caller-owned metadata persisted under user_metadata.

Values must already be JSON-compatible. This metadata is structurally separate from scientific payloads and is written only to metadata.json.

Source

pub fn with_shared_stream_limits( self, max_chunk_bytes: NonZeroU64, queue_bytes: NonZeroU64, ) -> Self

Uses one chunk target and one bounded-queue budget for concise stream declarations.

Limits supplied directly through StateStreamConfig::new remain stream-specific and take precedence. Streams constructed with storage_limits == None require these shared limits.

Source

pub fn with_task_parameters(self, parameters: &TaskParameters) -> Self

Merges one resolved task dictionary into the recording’s user metadata.

Fixed and swept values retain their resolved JSON representation. The synthetic task_ordinal entry is always set from the task itself and therefore replaces any same-named input entry. Task values also replace same-named caller metadata, while unrelated metadata and RNG records are preserved. On a key collision, the most recently supplied source wins.

Source

pub fn add_state_stream(self, stream: StateStreamConfig) -> Self

Appends one logical stream declaration in deterministic metadata order.

Duplicate names or directories are reported at start so fluent builder assembly remains infallible.

Source

pub fn create_new_recording(self) -> Result<SystemStateWriter, StorageError>

Validates the complete run, creates its exclusive output root, starts each bounded writer, and publishes initial metadata atomically.

§Errors

Returns StorageError::RecordingDirectoryExists rather than replacing any existing filesystem entry. Configuration, state-key selection, directory creation, thread startup, JSON, and metadata durability failures retain their precise StorageError context. If startup fails after the root is created, the path is retained as diagnostic evidence and is never silently removed.

Source

pub fn continue_existing_recording( self, ) -> Result<SystemStateWriter, StorageError>

Continues append writing in an existing running recording directory.

The complete builder configuration is compared with authoritative metadata before any chunk is recovered. Only the highest open chunk in each stream may be examined. This append-only entry point does not reconstruct scientific state; callers requiring a verified checkpoint must use Self::continue_recording_from_latest_checkpoint.

Source

pub fn continue_recording_from_latest_checkpoint( self, stream: &str, decoders: JsonPayloadDecoderRegistry, ) -> Result<(SystemStateWriter, SystemState), StorageError>

Resumes a run and reconstructs its newest complete checkpoint state.

stream must cover the builder’s complete state specification, and decoders must cover every field. The returned state owns all decoded payloads. When reconstruction selects a sealed chunk, its exact byte count and SHA-256 checksum are verified before its final record is decoded. Writer threads begin only after reconstruction succeeds.

Trait Implementations§

Source§

impl Debug for SystemStateWriterBuilder

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