pub struct Annotated<T, R>where
R: Reducer<T>,{
pub value: T,
/* private fields */
}Expand description
Newtype that bundles a value T with the reducer R that should
merge it. The wrapper is a standalone helper users compose into
their state types; it does not hook into StateGraph::add_node
directly.
Fields§
§value: TThe current value.
Implementations§
Source§impl<T, R> Annotated<T, R>where
R: Reducer<T>,
impl<T, R> Annotated<T, R>where
R: Reducer<T>,
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Consume the wrapper and return the inner value.
Sourcepub fn reduce_in_place(&mut self, update: T)where
T: Default,
pub fn reduce_in_place(&mut self, update: T)where
T: Default,
Apply the bundled reducer to fold update into self.value.
Sourcepub fn reduced(self, update: T) -> Selfwhere
R: Clone,
pub fn reduced(self, update: T) -> Selfwhere
R: Clone,
Consume self, return a new Annotated<T, R> with update
folded in.
Sourcepub fn merge(self, other: Self) -> Self
pub fn merge(self, other: Self) -> Self
Merge two annotated values. Both sides must agree on the
reducer type by construction (they share R); the resulting
Annotated keeps self’s reducer instance — this matters
for stateful reducers, where the current slot’s reducer
has the right configuration. Stock reducers
(Replace, Append, MergeMap, Max) are unit
structs, so the choice is moot for them.
This is the building block the StateMerge derive macro
emits per Annotated<T, R> field.