Skip to main content

ActionStore

Trait ActionStore 

Source
pub trait ActionStore: Send + Sync {
    // Required methods
    fn record_action(
        &self,
        request: ActionRequest,
        decision: PolicyDecision,
    ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>;
    fn record_action_against(
        &self,
        print_id: PrintId,
        request: ActionRequest,
        decision: PolicyDecision,
    ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>;
    fn record_execution(
        &self,
        action_id: ActionId,
        outcome: ExecutionOutcome,
    ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>;
    fn open_intervention(
        &self,
        action_id: ActionId,
        adjustable: Adjustable,
        prior_value: Option<f64>,
        applied_value: f64,
        applied_at: Timestamp,
        expires_at: Timestamp,
    ) -> BoxFuture<'_, Result<Intervention, StoreError>>;
    fn settle_intervention(
        &self,
        intervention_id: InterventionId,
        outcome: InterventionOutcome,
    ) -> BoxFuture<'_, Result<SettleOutcome, StoreError>>;
    fn due_interventions(
        &self,
        at: Timestamp,
    ) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>;
    fn active_interventions(
        &self,
        print_id: PrintId,
    ) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>;
}
Expand description

Actions, and the bounded interventions they open.

Every method is asynchronous, the trait is dyn-compatible, and it is shareable across threads, because its consumers hold it behind Arc<dyn ActionStore>.

Required Methods§

Source

fn record_action( &self, request: ActionRequest, decision: PolicyDecision, ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>

Record one request together with the decision taken on it.

This and ActionStore::record_action_against are the only methods that take either half, and they take them only together; the ActionId each answers is minted for the pair.

Source

fn record_action_against( &self, print_id: PrintId, request: ActionRequest, decision: PolicyDecision, ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>

Record one request together with the decision taken on it, against the print it names rather than the one the store would bind it to.

A close is asked of one record, which may have ended or may not be the newest open one, so its request is recorded against that record or refused as StoreError::NotFound when there is none.

Source

fn record_execution( &self, action_id: ActionId, outcome: ExecutionOutcome, ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>

Record what the printer made of an action that reached it.

Source

fn open_intervention( &self, action_id: ActionId, adjustable: Adjustable, prior_value: Option<f64>, applied_value: f64, applied_at: Timestamp, expires_at: Timestamp, ) -> BoxFuture<'_, Result<Intervention, StoreError>>

Open a bounded intervention, minting its identifier.

The print is the one the action was recorded against, so that a caller cannot name a print the action does not belong to.

Source

fn settle_intervention( &self, intervention_id: InterventionId, outcome: InterventionOutcome, ) -> BoxFuture<'_, Result<SettleOutcome, StoreError>>

Settle one intervention, or report the outcome that already won.

Source

fn due_interventions( &self, at: Timestamp, ) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>

Read every intervention due to expire at or before an instant.

Source

fn active_interventions( &self, print_id: PrintId, ) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>

Read every intervention still active on one print.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§