Skip to main content

BoxStateStore

Struct BoxStateStore 

Source
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

Source

pub fn from_records(path: impl Into<PathBuf>, records: Vec<BoxRecord>) -> Self

Build an in-memory store for path from existing records.

Source

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.

Source

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.

Source

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.

Source

pub fn save(&self) -> Result<()>

Save this snapshot under the cross-process state lock.

Source

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.

Source

pub fn transact<R, E>( path: &Path, f: impl FnOnce(&mut Self) -> Result<R, E>, ) -> Result<R, E>
where E: From<Error>,

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.

Source

pub fn modify_or_quarantine<R, E>( path: &Path, f: impl FnOnce(&mut Self) -> Result<R, E>, ) -> Result<R, E>
where E: From<Error>,

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.

Source

pub fn path(&self) -> &Path

Path of the durable state file.

Source

pub fn records(&self) -> &[BoxRecord]

All execution records in persistence order.

Source

pub fn records_mut(&mut self) -> &mut Vec<BoxRecord>

Mutable execution records for a synchronous transaction.

Source

pub fn find_by_id(&self, id: &str) -> Option<&BoxRecord>

Find a record by exact execution ID.

Source

pub fn find_by_id_mut(&mut self, id: &str) -> Option<&mut BoxRecord>

Find a mutable record by exact execution ID.

Source

pub fn remove_by_id(&mut self, id: &str) -> bool

Remove a record by exact execution ID.

Source

pub fn find_by_name(&self, name: &str) -> Option<&BoxRecord>

Find a record by exact user-visible name.

Source

pub fn find_by_operation_id( &self, operation_id: &OperationId, ) -> Option<&BoxRecord>

Find a managed execution by its idempotent creation operation.

Source

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.

Source

pub fn find_by_id_prefix(&self, prefix: &str) -> Vec<&BoxRecord>

Find records matching a full-ID or short-ID prefix.

Source

pub fn list(&self, all: bool) -> Vec<&BoxRecord>

List all records or only records in the running state.

Trait Implementations§

Source§

impl Debug for BoxStateStore

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more