Expand description
§Zed - Advanced State Management for Rust
Zed is a comprehensive state management library that provides Redux-like patterns with advanced features for modern Rust applications.
§Features
- Redux-like Store: Centralized, predictable state management
- Timeline: Time-reversible state with history and branching
- State Mesh: Distributed state nodes with conflict resolution
- Capsules: Encapsulated state domains with caching
- Reactive System: Cascade-triggered reactive updates
§Quick Start
use serde::{Deserialize, Serialize};
use zed::*;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CounterState {
pub value: i32,
pub is_loading: bool,
}
create_slice! {
enum_name: CounterActions,
fn_base: counter,
state: CounterState,
initial_state: CounterState { value: 0, is_loading: false },
actions: {
Increment,
Decrement,
},
reducer: |state: &mut CounterState, action: &CounterActions| {
match action {
CounterActions::Increment => state.value += 1,
CounterActions::Decrement => state.value -= 1,
}
}
}
let store = counter_store();
store.subscribe(|state: &CounterState| {
println!("State: {:?}", state);
});
store.dispatch(CounterActions::Increment);
Re-exports§
pub use capsule::Cache;
pub use capsule::Capsule;
pub use configure_store::configure_store;
pub use reactive::ReactiveSystem;
pub use reducer::ClosureReducer;
pub use reducer::Reducer;
pub use reducer::create_reducer;
pub use simple_cache::SimpleCache;
pub use state_mesh::StateNode;
pub use store::Store;
pub use timeline::StateManager;
Modules§
- capsule
- configure_
store - Configure Store Module
- create_
slice - reactive
- reducer
- Reducer Module
- simple_
cache - Simple Cache Module
- state_
mesh - State Mesh Module
- store
- Store Module
- timeline
- Timeline Module