pub trait PhaseHandler<Input, Output, State>: Send + Sync{
// Required methods
fn name(&self) -> &str;
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
input: Input,
ctx: &'life1 mut SecretaryContext<State>,
) -> Pin<Box<dyn Future<Output = Result<PhaseResult<Output>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn can_skip(&self, _input: &Input, _ctx: &SecretaryContext<State>) -> bool { ... }
}Expand description
阶段处理器Trait
用于实现工作流中的单个阶段。每个阶段接收输入,处理后产生输出。 这允许将复杂的处理逻辑拆分成多个独立的阶段。
§类型参数
Input: 阶段接收的输入类型Output: 阶段产生的输出类型State: 秘书状态类型
Required Methods§
Sourcefn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
input: Input,
ctx: &'life1 mut SecretaryContext<State>,
) -> Pin<Box<dyn Future<Output = Result<PhaseResult<Output>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle<'life0, 'life1, 'async_trait>(
&'life0 self,
input: Input,
ctx: &'life1 mut SecretaryContext<State>,
) -> Pin<Box<dyn Future<Output = Result<PhaseResult<Output>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
处理输入
Provided Methods§
Sourcefn can_skip(&self, _input: &Input, _ctx: &SecretaryContext<State>) -> bool
fn can_skip(&self, _input: &Input, _ctx: &SecretaryContext<State>) -> bool
是否可以跳过此阶段