Skip to main content

AppendReducer

Struct AppendReducer 

Source
pub struct AppendReducer<S: StateSchema, T: Clone + Send + Sync> {
    pub field_accessor: fn(&S) -> &[T],
    pub field_mutator: fn(&mut S, Vec<T>),
}
Expand description

Append reducer for vector fields (like add_messages pattern)

This reducer appends new items to vector fields in the state. Useful for message history, steps history, etc.

Fields§

§field_accessor: fn(&S) -> &[T]

Function that reads the vector field from a state.

§field_mutator: fn(&mut S, Vec<T>)

Function that writes the merged vector back into a state.

Trait Implementations§

Source§

impl<S: StateSchema, T: Clone + Send + Sync> Reducer<S> for AppendReducer<S, T>

Source§

fn reduce(&self, current: &S, update: &S) -> S

Reduce current state with an update

Auto Trait Implementations§

§

impl<S, T> Freeze for AppendReducer<S, T>
where fn(&S) -> &[T]: Freeze, fn(&mut S, Vec<T>): Freeze,

§

impl<S, T> RefUnwindSafe for AppendReducer<S, T>

§

impl<S, T> Send for AppendReducer<S, T>
where fn(&S) -> &[T]: Send, fn(&mut S, Vec<T>): Send,

§

impl<S, T> Sync for AppendReducer<S, T>
where fn(&S) -> &[T]: Sync, fn(&mut S, Vec<T>): Sync,

§

impl<S, T> Unpin for AppendReducer<S, T>
where fn(&S) -> &[T]: Unpin, fn(&mut S, Vec<T>): Unpin,

§

impl<S, T> UnsafeUnpin for AppendReducer<S, T>
where fn(&S) -> &[T]: UnsafeUnpin, fn(&mut S, Vec<T>): UnsafeUnpin,

§

impl<S, T> UnwindSafe for AppendReducer<S, T>
where fn(&S) -> &[T]: UnwindSafe, fn(&mut S, Vec<T>): UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.