pub struct ReducerRegistry { /* private fields */ }Expand description
Maps channel types to ordered lists of reducers applied during state updates.
Implementations§
Source§impl ReducerRegistry
impl ReducerRegistry
Sourcepub fn register(
&mut self,
channel: ChannelType,
reducer: Arc<dyn Reducer>,
) -> &mut Self
pub fn register( &mut self, channel: ChannelType, reducer: Arc<dyn Reducer>, ) -> &mut Self
Appends reducer to the list for channel. Multiple reducers run in registration order.
Sourcepub fn with_reducer(
self,
channel: ChannelType,
reducer: Arc<dyn Reducer>,
) -> Self
pub fn with_reducer( self, channel: ChannelType, reducer: Arc<dyn Reducer>, ) -> Self
Owned builder variant of register.
use std::sync::Arc;
use weavegraph::reducers::{ReducerRegistry, AddMessages};
use weavegraph::types::ChannelType;
let registry = ReducerRegistry::new()
.with_reducer(ChannelType::Message, Arc::new(AddMessages));Sourcepub fn definition_signature(&self) -> Vec<String>
pub fn definition_signature(&self) -> Vec<String>
Returns a sorted, deterministic summary of all registered reducer labels.
The signature changes when reducers are added, removed, reordered, or replaced
with a reducer that reports a different Reducer::definition_label.
Sourcepub fn try_update(
&self,
channel_type: ChannelType,
state: &mut VersionedState,
to_update: &NodePartial,
) -> Result<(), ReducerError>
pub fn try_update( &self, channel_type: ChannelType, state: &mut VersionedState, to_update: &NodePartial, ) -> Result<(), ReducerError>
Applies all reducers registered for channel_type to state.
Returns Ok(()) immediately if to_update carries no data for the channel.
Returns Err(ReducerError::UnknownChannel) if no reducers are registered.
Sourcepub fn apply_all(
&self,
state: &mut VersionedState,
merged_updates: &NodePartial,
) -> Result<(), ReducerError>
pub fn apply_all( &self, state: &mut VersionedState, merged_updates: &NodePartial, ) -> Result<(), ReducerError>
Applies all registered reducers across every channel to state.
Trait Implementations§
Source§impl Clone for ReducerRegistry
impl Clone for ReducerRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for ReducerRegistry
impl !UnwindSafe for ReducerRegistry
impl Freeze for ReducerRegistry
impl Send for ReducerRegistry
impl Sync for ReducerRegistry
impl Unpin for ReducerRegistry
impl UnsafeUnpin for ReducerRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more