pub struct BoxStateStore { /* private fields */ }Expand description
Durable collection of local box execution records.
All mutating operations use the sibling boxes.json.lock advisory lock and
a durable temporary-file rename. Callers must keep transaction closures
synchronous and must not acquire the same store lock recursively.
Implementations§
Source§impl BoxStateStore
impl BoxStateStore
Sourcepub fn from_records(path: impl Into<PathBuf>, records: Vec<BoxRecord>) -> Self
pub fn from_records(path: impl Into<PathBuf>, records: Vec<BoxRecord>) -> Self
Build an in-memory store for path from existing records.
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Load state strictly, returning invalid JSON or schema data as an error.
A missing state file is represented by an empty store and its parent directory is created for subsequent writes.
Sourcepub fn load_or_quarantine(path: &Path) -> Result<Self>
pub fn load_or_quarantine(path: &Path) -> Result<Self>
Load state and preserve an invalid file as a timestamped sibling.
This compatibility path keeps the CLI available for manual recovery.
New runtime services should prefer Self::load and fail closed.
Sourcepub fn load_readonly(path: impl Into<PathBuf>) -> Result<Self>
pub fn load_readonly(path: impl Into<PathBuf>) -> Result<Self>
Load a side-effect-free snapshot.
This never creates directories, quarantines invalid data, acquires a lock, reconciles process state, or writes the file back.
Sourcepub fn modify<R>(
path: &Path,
f: impl FnOnce(&mut Self) -> Result<R>,
) -> Result<R>
pub fn modify<R>( path: &Path, f: impl FnOnce(&mut Self) -> Result<R>, ) -> Result<R>
Apply a strict atomic read-modify-write transaction.
The closure runs while the cross-process lock is held. If it returns an error, no write is performed.
Sourcepub fn transact<R, E>(
path: &Path,
f: impl FnOnce(&mut Self) -> Result<R, E>,
) -> Result<R, E>
pub fn transact<R, E>( path: &Path, f: impl FnOnce(&mut Self) -> Result<R, E>, ) -> Result<R, E>
Apply a strict atomic transaction with a caller-defined error type.
This is equivalent to Self::modify but lets a domain repository
return typed conflicts while still converting state I/O errors.
Sourcepub fn modify_or_quarantine<R, E>(
path: &Path,
f: impl FnOnce(&mut Self) -> Result<R, E>,
) -> Result<R, E>
pub fn modify_or_quarantine<R, E>( path: &Path, f: impl FnOnce(&mut Self) -> Result<R, E>, ) -> Result<R, E>
Apply an atomic read-modify-write transaction that quarantines invalid existing state before starting from an empty collection.
This exists for CLI behavior compatibility. Runtime services should use
Self::modify so corrupt durable state fails closed.
Sourcepub fn records_mut(&mut self) -> &mut Vec<BoxRecord>
pub fn records_mut(&mut self) -> &mut Vec<BoxRecord>
Mutable execution records for a synchronous transaction.
Sourcepub fn find_by_id(&self, id: &str) -> Option<&BoxRecord>
pub fn find_by_id(&self, id: &str) -> Option<&BoxRecord>
Find a record by exact execution ID.
Sourcepub fn find_by_id_mut(&mut self, id: &str) -> Option<&mut BoxRecord>
pub fn find_by_id_mut(&mut self, id: &str) -> Option<&mut BoxRecord>
Find a mutable record by exact execution ID.
Sourcepub fn remove_by_id(&mut self, id: &str) -> bool
pub fn remove_by_id(&mut self, id: &str) -> bool
Remove a record by exact execution ID.
Sourcepub fn find_by_name(&self, name: &str) -> Option<&BoxRecord>
pub fn find_by_name(&self, name: &str) -> Option<&BoxRecord>
Find a record by exact user-visible name.
Sourcepub fn find_by_operation_id(
&self,
operation_id: &OperationId,
) -> Option<&BoxRecord>
pub fn find_by_operation_id( &self, operation_id: &OperationId, ) -> Option<&BoxRecord>
Find a managed execution by its idempotent creation operation.
Sourcepub fn find_by_operation_id_mut(
&mut self,
operation_id: &OperationId,
) -> Option<&mut BoxRecord>
pub fn find_by_operation_id_mut( &mut self, operation_id: &OperationId, ) -> Option<&mut BoxRecord>
Find a mutable managed execution by its idempotent creation operation.
Sourcepub fn find_by_id_prefix(&self, prefix: &str) -> Vec<&BoxRecord>
pub fn find_by_id_prefix(&self, prefix: &str) -> Vec<&BoxRecord>
Find records matching a full-ID or short-ID prefix.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoxStateStore
impl RefUnwindSafe for BoxStateStore
impl Send for BoxStateStore
impl Sync for BoxStateStore
impl Unpin for BoxStateStore
impl UnsafeUnpin for BoxStateStore
impl UnwindSafe for BoxStateStore
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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