pub trait Reducer: Send + Sync {
// Required methods
fn reduce<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
current: Option<&'life1 Value>,
update: &'life2 Value,
) -> Pin<Box<dyn Future<Output = AgentResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn name(&self) -> &str;
fn reducer_type(&self) -> ReducerType;
}Expand description
Reducer trait for state update strategies
A Reducer defines how to merge a state update with an existing value. Different keys in the state can have different reducers.
§Example
ⓘ
// Messages should be appended
graph.add_reducer("messages", Box::new(AppendReducer));
// Result should overwrite
graph.add_reducer("result", Box::new(OverwriteReducer));Required Methods§
Sourcefn reduce<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
current: Option<&'life1 Value>,
update: &'life2 Value,
) -> Pin<Box<dyn Future<Output = AgentResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn reduce<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
current: Option<&'life1 Value>,
update: &'life2 Value,
) -> Pin<Box<dyn Future<Output = AgentResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn reducer_type(&self) -> ReducerType
fn reducer_type(&self) -> ReducerType
Returns the type of this reducer