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§
Sourcefn 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 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,
初始化插件状态
Sourcefn 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 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,
应用状态变更
Implementors§
impl<T: StateField + 'static> ErasedStateField for T
StateField 到 ErasedStateField 的自动实现