ProtocolAdapter

Trait ProtocolAdapter 

Source
pub trait ProtocolAdapter: Send + Sync {
    // Required methods
    fn protocol(&self) -> Protocol;
    fn on_state_change<'life0, 'life1, 'async_trait>(
        &'life0 self,
        event: &'life1 StateChangeEvent,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_current_state<'life0, 'life1, 'async_trait>(
        &'life0 self,
        workspace_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ProtocolState>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn apply_persona<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        workspace_id: &'life1 str,
        persona: &'life2 PersonaProfile,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn apply_scenario<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        workspace_id: &'life1 str,
        scenario_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Trait for protocol adapters

Protocol adapters integrate individual protocols with the consistency engine. They receive state change events and update their protocol-specific state to reflect the unified state.

Required Methods§

Source

fn protocol(&self) -> Protocol

Get the protocol this adapter handles

Source

fn on_state_change<'life0, 'life1, 'async_trait>( &'life0 self, event: &'life1 StateChangeEvent, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Handle a state change event

Called by the consistency engine when state changes. The adapter should update its internal state to reflect the change.

Source

fn get_current_state<'life0, 'life1, 'async_trait>( &'life0 self, workspace_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ProtocolState>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get current protocol state

Returns the current state of this protocol for the given workspace, or None if the workspace doesn’t exist or has no state for this protocol.

Source

fn apply_persona<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, workspace_id: &'life1 str, persona: &'life2 PersonaProfile, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Apply persona to this protocol

Called when a persona is set for a workspace. The adapter should update its handlers/middleware to use this persona for data generation.

Source

fn apply_scenario<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, workspace_id: &'life1 str, scenario_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Apply scenario to this protocol

Called when a scenario is set for a workspace. The adapter should update its state machine or workflow to reflect this scenario.

Implementors§