pub struct StateSchema {
pub channels: HashMap<String, Channel>,
}Expand description
State schema defines channels and their reducers
Fields§
§channels: HashMap<String, Channel>Channel definitions
Implementations§
Source§impl StateSchema
impl StateSchema
Sourcepub fn builder() -> StateSchemaBuilder
pub fn builder() -> StateSchemaBuilder
Create a schema builder
Sourcepub fn simple(channels: &[&str]) -> Self
pub fn simple(channels: &[&str]) -> Self
Create a simple schema with just channel names (all overwrite)
Sourcepub fn get_reducer(&self, channel: &str) -> &Reducer
pub fn get_reducer(&self, channel: &str) -> &Reducer
Get the reducer for a channel
Sourcepub fn get_default(&self, channel: &str) -> Option<&Value>
pub fn get_default(&self, channel: &str) -> Option<&Value>
Get the default value for a channel
Sourcepub fn apply_update(&self, state: &mut State, key: &str, value: Value)
pub fn apply_update(&self, state: &mut State, key: &str, value: Value)
Apply an update to state using the appropriate reducer
Sourcepub fn initialize_state(&self) -> State
pub fn initialize_state(&self) -> State
Initialize state with default values
Trait Implementations§
Source§impl Clone for StateSchema
impl Clone for StateSchema
Source§fn clone(&self) -> StateSchema
fn clone(&self) -> StateSchema
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for StateSchema
impl Default for StateSchema
Source§fn default() -> StateSchema
fn default() -> StateSchema
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StateSchema
impl !RefUnwindSafe for StateSchema
impl Send for StateSchema
impl Sync for StateSchema
impl Unpin for StateSchema
impl !UnwindSafe for StateSchema
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)