ErasedStateField

Trait ErasedStateField 

Source
pub trait ErasedStateField:
    Send
    + Sync
    + Debug {
    // Required methods
    fn init_erased<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        config: &'life1 StateConfig,
        instance: &'life2 State,
    ) -> Pin<Box<dyn Future<Output = Arc<dyn Resource>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn apply_erased<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tr: &'life1 Transaction,
        value: Arc<dyn Resource>,
        old_state: &'life2 State,
        new_state: &'life3 State,
    ) -> Pin<Box<dyn Future<Output = Arc<dyn Resource>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn serialize_erased(&self, value: Arc<dyn Resource>) -> Option<Vec<u8>>;
    fn deserialize_erased(&self, data: &[u8]) -> Option<Arc<dyn Resource>>;
}
Expand description

类型擦除的 StateField trait 用于在 PluginSpec 中存储不同类型的 StateField

Required Methods§

Source

fn init_erased<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, config: &'life1 StateConfig, instance: &'life2 State, ) -> Pin<Box<dyn Future<Output = Arc<dyn Resource>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

初始化插件状态

Source

fn apply_erased<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tr: &'life1 Transaction, value: Arc<dyn Resource>, old_state: &'life2 State, new_state: &'life3 State, ) -> Pin<Box<dyn Future<Output = Arc<dyn Resource>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

应用状态变更

Source

fn serialize_erased(&self, value: Arc<dyn Resource>) -> Option<Vec<u8>>

序列化插件状态

Source

fn deserialize_erased(&self, data: &[u8]) -> Option<Arc<dyn Resource>>

反序列化插件状态

Implementors§

Source§

impl<T: StateField + 'static> ErasedStateField for T

StateField 到 ErasedStateField 的自动实现