pub trait StateField:
Send
+ Sync
+ Debug {
// Required methods
fn init<'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 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn apply<'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 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
// Provided methods
fn serialize(&self, _value: Arc<dyn Resource>) -> Option<Vec<u8>> { ... }
fn deserialize(&self, _value: &Vec<u8>) -> Option<Arc<dyn Resource>> { ... }
}
Expand description
PluginTrait实现一个 default 实现 状态字段特征 定义插件状态的管理方式,包括初始化、应用更改和序列化
Required Methods§
Sourcefn init<'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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn init<'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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
初始化插件状态
Sourcefn apply<'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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn apply<'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
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
应用状态变更 根据事务内容更新插件状态