Skip to main content

BusinessStateStore

Struct BusinessStateStore 

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

Thread-safe host-owned authoritative business state store surviving hot-swaps and rollbacks.

Implementations§

Source§

impl BusinessStateStore

Authoritative business state orchestration on BusinessStateStore.

Source

pub fn new(delta_cap: usize) -> Self

Creates a new BusinessStateStore retaining up to delta_cap historical deltas per entity.

§Arguments
  • usize - Maximum per-entity delta history length.
§Returns
  • Self - Initialized authoritative store.
Source

pub fn seed_entity( &self, entity_id: &str, state: Value, ) -> Result<u64, DynamicReleaseError>

Seeds or initializes an authoritative entity at revision 1 if absent and returns its revision.

§Arguments
  • &str - Entity identifier.
  • Value - Initial authoritative state.
§Returns
  • Result<u64, DynamicReleaseError> - Entity revision after seeding.
Source

pub fn read_entity(&self, entity_id: &str) -> Option<(u64, Value)>

Reads the current authoritative (revision, state) pair for entity_id.

§Arguments
  • &str - Entity identifier.
§Returns
  • Option<(u64, Value)> - Revision and cloned authoritative state if present.
Source

pub fn global_revision(&self) -> u64

Returns the monotonic global store revision across all entities.

§Returns
  • u64 - Global authoritative revision number.
Source

pub fn capture_entity_snapshots(&self) -> (u64, BTreeMap<String, (u64, Value)>)

Captures a read-only snapshot of all entities and the global revision R.

§Returns
  • (u64, BTreeMap<String, (u64, Value)>) - Global revision R paired with per-entity snapshots.
Source

pub fn subscribe_entity( &self, entity_id: &str, generation_id: u64, watched_fields: Vec<String>, ) -> Result<u64, DynamicReleaseError>

Registers a field-filtered subscriber for entity_id owned by generation_id.

§Arguments
  • &str - Target entity identifier.
  • u64 - Owning release generation identifier.
  • Vec<String> - Subset of watched fields (empty watches all changes).
§Returns
  • Result<u64, DynamicReleaseError> - Assigned subscription identifier.
Source

pub fn cancel_generation_subscriptions(&self, generation_id: u64)

Cancels all subscriptions belonging to generation_id so destroyed instances never receive callbacks.

§Arguments
  • u64 - Retired release generation identifier.
Source

pub fn delivered_revisions(&self, subscription_id: u64) -> Vec<u64>

Returns the list of revisions delivered to subscription subscription_id.

§Arguments
  • u64 - Subscription identifier.
§Returns
  • Vec<u64> - Delivered entity revision numbers.
Source

pub fn begin_operation( &self, command: BusinessCommand, ) -> Result<CommandOutcome, DynamicReleaseError>

Accepts an asynchronous business command into host-owned in-flight tracking, returning its OperationId.

§Arguments
  • BusinessCommand - Command submitted by a page or dynamic component.
§Returns
  • Result<CommandOutcome, DynamicReleaseError> - Pending or deduplicated Committed / Rejected* outcome.
Source

pub fn complete_operation( &self, operation_id: OperationId, next_state: Value, changed_fields: Vec<String>, ) -> Result<CommandOutcome, DynamicReleaseError>

Completes a previously accepted host-owned in-flight operation regardless of component hot-swaps.

§Arguments
  • OperationId - Host-assigned operation identifier returned by begin_operation.
  • Value - Authoritative post-operation entity state.
  • Vec<String> - Field names mutated by this completion.
§Returns
  • Result<CommandOutcome, DynamicReleaseError> - Committed outcome or conflict error.
Source

pub fn commit_command( &self, command: BusinessCommand, next_state: Value, changed_fields: Vec<String>, ) -> Result<CommandOutcome, DynamicReleaseError>

Synchronously validates, commits, and deduplicates a typed command in a single atomic host step.

§Arguments
  • BusinessCommand - Typed mutation command.
  • Value - Resulting authoritative entity state.
  • Vec<String> - Mutated field names.
§Returns
  • Result<CommandOutcome, DynamicReleaseError> - Committed or rejected outcome.
Source

pub fn deltas_since( &self, entity_id: &str, base_revision: u64, ) -> Result<Vec<BusinessStateDelta>, DynamicReleaseError>

Returns all authoritative deltas strictly newer than base_revision for entity_id, or StateCatchUpConflict if history wrapped.

§Arguments
  • &str - Entity identifier.
  • u64 - Snapshot baseline revision R.
§Returns
  • Result<Vec<BusinessStateDelta>, DynamicReleaseError> - Ordered catch-up deltas from R+1 to R+n.
Source

pub fn active_in_flight_count(&self) -> usize

Returns the number of currently active host-owned in-flight operations.

§Returns
  • usize - Count of pending in-flight operations.

Trait Implementations§

Source§

impl Clone for BusinessStateStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BusinessStateStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BusinessStateStore

Default empty BusinessStateStore.

Source§

fn default() -> Self

Creates a BusinessStateStore with DEFAULT_STATE_DELTA_HISTORY_CAP.

§Returns
  • Self - Empty authoritative business state store.

Auto Trait Implementations§

§

impl Forget for BusinessStateStore

§

impl Freeze for BusinessStateStore
where *const ArcInner<Mutex<BusinessStateStoreInner>> is !null: Freeze, PhantomData<ArcInner<Mutex<BusinessStateStoreInner>>>: Freeze,

§

impl Move for BusinessStateStore

§

impl RefUnwindSafe for BusinessStateStore
where Atomic<usize>: RefUnwindSafe, Mutex<BusinessStateStoreInner>: RefUnwindSafe,

§

impl Send for BusinessStateStore
where Arc<Mutex<BusinessStateStoreInner>>: Send,

§

impl Sync for BusinessStateStore
where Arc<Mutex<BusinessStateStoreInner>>: Sync,

§

impl Unpin for BusinessStateStore
where Arc<Mutex<BusinessStateStoreInner>>: Unpin,

§

impl UnsafeUnpin for BusinessStateStore
where *const ArcInner<Mutex<BusinessStateStoreInner>> is !null: UnsafeUnpin, PhantomData<ArcInner<Mutex<BusinessStateStoreInner>>>: UnsafeUnpin,

§

impl UnwindSafe for BusinessStateStore
where Arc<Mutex<BusinessStateStoreInner>>: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.