Skip to main content

CaseLoader

Trait CaseLoader 

Source
pub trait CaseLoader<W: WorkflowDefinition>: Send + Sync {
    // Required method
    fn load_case<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        account: &'life1 AccountId,
        case_id: &'life2 CaseId,
    ) -> Pin<Box<dyn Future<Output = Result<Versioned<Option<W::State>>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

The read-only half of WorkflowExecutor: loading a case, and nothing else (spec §8.2).

It exists for callers that must be unable to mutate a case — the plan-only turn path of turnframe-runtime above all, which needs the state a turn is planned against and must not be able to execute a batch. A guarantee that says “this code simply never calls execute” is not a guarantee; being handed a value that has no execute is.

There is nothing to implement. Every WorkflowExecutor is a CaseLoader through the blanket implementation below, so an adopter writes exactly what they write today. The method is called load_case rather than load so that a type which is both never makes a call site ambiguous.

/// Accepts any executor, but can only read through it.
fn planning_only<W: WorkflowDefinition, E: WorkflowExecutor<W>>(executor: E) -> impl CaseLoader<W> {
    executor
}

Required Methods§

Source

fn load_case<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, account: &'life1 AccountId, case_id: &'life2 CaseId, ) -> Pin<Box<dyn Future<Output = Result<Versioned<Option<W::State>>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Loads a case for an account. None value means the case does not exist; its revision is then crate::ids::CaseRevision::ZERO. See WorkflowExecutor::load for what an absent state does and does not mean.

§Errors

StoreError when the case could not be read.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<W, E> CaseLoader<W> for E

Every executor loads.