pub struct ReducerRegistry { /* private fields */ }Expand description
Reducer 注册表 — 管理每个 key 的合并策略。
Implementations§
Source§impl ReducerRegistry
impl ReducerRegistry
pub fn new() -> Self
pub fn register(&mut self, key: &str, reducer: Reducer)
pub fn register_custom( &mut self, key: &str, f: impl Fn(&Value, &Value) -> Result<Value, String> + Send + Sync + 'static, )
pub fn get(&self, key: &str) -> &Reducer
pub fn apply_custom( &self, key: &str, existing: &Value, new_val: &Value, ) -> Result<Option<Value>, String>
pub fn apply_delta( &self, state: &mut HashMap<String, Value>, delta: &StateDelta, ) -> Result<(), StateError>
pub fn merge_deltas( &self, state: &mut HashMap<String, Value>, deltas: &[StateDelta], ) -> Result<(), StateError>
Trait Implementations§
Source§impl Debug for ReducerRegistry
impl Debug for ReducerRegistry
Source§impl Default for ReducerRegistry
impl Default for ReducerRegistry
Source§fn default() -> ReducerRegistry
fn default() -> ReducerRegistry
Returns the “default value” for a type. Read more
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