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§
Sourcefn record_action(
&self,
request: ActionRequest,
decision: PolicyDecision,
) -> BoxFuture<'_, Result<ActionRecord, StoreError>>
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.
Sourcefn record_action_against(
&self,
print_id: PrintId,
request: ActionRequest,
decision: PolicyDecision,
) -> BoxFuture<'_, Result<ActionRecord, StoreError>>
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.
Sourcefn record_execution(
&self,
action_id: ActionId,
outcome: ExecutionOutcome,
) -> BoxFuture<'_, Result<ActionRecord, StoreError>>
fn record_execution( &self, action_id: ActionId, outcome: ExecutionOutcome, ) -> BoxFuture<'_, Result<ActionRecord, StoreError>>
Record what the printer made of an action that reached it.
Sourcefn 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 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.
Sourcefn settle_intervention(
&self,
intervention_id: InterventionId,
outcome: InterventionOutcome,
) -> BoxFuture<'_, Result<SettleOutcome, StoreError>>
fn settle_intervention( &self, intervention_id: InterventionId, outcome: InterventionOutcome, ) -> BoxFuture<'_, Result<SettleOutcome, StoreError>>
Settle one intervention, or report the outcome that already won.
Sourcefn due_interventions(
&self,
at: Timestamp,
) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>
fn due_interventions( &self, at: Timestamp, ) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>
Read every intervention due to expire at or before an instant.
Sourcefn active_interventions(
&self,
print_id: PrintId,
) -> BoxFuture<'_, Result<Vec<Intervention>, StoreError>>
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".