pub trait StateField:
Send
+ Sync
+ Debug {
// Required methods
fn init<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
config: &'life1 StateConfig,
instance: Option<&'life2 State>,
) -> Pin<Box<dyn Future<Output = PluginState> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn apply<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tr: &'life1 Transaction,
value: PluginState,
old_state: &'life2 State,
new_state: &'life3 State,
) -> Pin<Box<dyn Future<Output = PluginState> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided methods
fn serialize(&self, _value: PluginState) -> Option<Vec<u8>> { ... }
fn deserialize(&self, _value: &Vec<u8>) -> Option<PluginState> { ... }
}
Expand description
状态字段特征 定义插件状态的管理方式,包括初始化、应用更改和序列化
Required Methods§
Sourcefn init<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
config: &'life1 StateConfig,
instance: Option<&'life2 State>,
) -> Pin<Box<dyn Future<Output = PluginState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn init<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
config: &'life1 StateConfig,
instance: Option<&'life2 State>,
) -> Pin<Box<dyn Future<Output = PluginState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
初始化插件状态
Sourcefn apply<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tr: &'life1 Transaction,
value: PluginState,
old_state: &'life2 State,
new_state: &'life3 State,
) -> Pin<Box<dyn Future<Output = PluginState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn apply<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tr: &'life1 Transaction,
value: PluginState,
old_state: &'life2 State,
new_state: &'life3 State,
) -> Pin<Box<dyn Future<Output = PluginState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
应用状态变更 根据事务内容更新插件状态
Provided Methods§
Sourcefn deserialize(&self, _value: &Vec<u8>) -> Option<PluginState>
fn deserialize(&self, _value: &Vec<u8>) -> Option<PluginState>
反序列化插件状态