Skip to main content

rust_elm/
lib.rs

1//! # rust-elm
2//!
3//! A Rust port of The Elm Architecture
4//!
5//! - **Pure descriptions**: `Cmd`, `Effect`, and `Sub` are data — interpretation lives in [`Runtime`].
6//! - **Zero-cost updates**: `update` uses fn pointers; no `Box<dyn Fn>` on hot paths.
7//! - **Composition**: [`Slot`](component::Slot), [`optics`](optics), [`Reducer`](reducer::Reducer) / `CombineReducers`.
8
9pub mod batch;
10pub mod bus;
11pub mod cmd;
12pub mod component;
13pub mod effect;
14pub mod env;
15pub mod error;
16pub mod interp;
17pub mod macros;
18pub mod optics;
19pub mod program;
20pub mod reducer;
21pub mod replay;
22pub mod runtime;
23pub mod scope;
24pub mod shared;
25pub mod store;
26pub mod sub;
27pub mod test_runtime;
28pub mod test_store;
29pub mod test_support;
30
31/// Re-export keypath types for state/action focusing (see `optics`).
32pub mod keypath {
33    pub use key_paths_core::{KeyPath, KpTrait, Readable, Writable};
34    pub use rust_key_paths::{EnumKp, EnumKpType, EnumValueKpType, Kp, KpType};
35}
36
37pub use batch::batch;
38pub use bus::{Bus, BusSender};
39pub use cmd::Cmd;
40pub use component::{lift, Slot};
41pub use effect::{Effect, EffectId, EnvTaskFn, RunSender, TaskFn};
42pub use dependencies::{
43    Clock, ClockDep, ClockKey, DepRng, DependencyError, DependencyKey, DependencyValues,
44    LiveRng, LiveUuidGen, Now, NowDep, NowKey, RealClock, RngDep, RngKey, SeededRng,
45    SeededUuidGen, TestClock, TestNow, UuidDep, UuidGen, UuidKey,
46};
47pub use rust_dependencies as dependencies;
48pub use env::{defer_batch, Environment, FakeClock, MockHttp};
49pub use error::EffectError;
50pub use interp::{flatten_effects, normalize, InterpretCtx};
51pub use rust_identified_vec::{Identifiable, IdentifiedVec};
52pub use optics::{
53    enum_err, enum_ok, enum_some, enum_variant, extract, extract_action, extract_mut, variant_of,
54    wrap_action, ActionCase, ActionEnum, CasePath, Casepath, EnumKp, EnumKpType, EnumValueKpType,
55    Kp, KpType, StateKey, StateKp, StateLens,
56};
57pub use program::{Program, ReducerProgram};
58pub use reducer::{coerce_fn, CatchReducer, CombineReducers, Reduce, Reducer, RollbackCatchReducer};
59pub use replay::{ReplayHarness, ReplayLog};
60#[cfg(feature = "serde")]
61pub use replay::StateSnapshot;
62pub use runtime::Runtime;
63pub use scope::{
64    lift_cmd, lift_cmd_with_id, ForEachReducer, IfCaseLetReducer, IfLetReducer, OptionalReducer,
65    ScopeReducer,
66};
67pub use shared::{InMemoryStorage, Shared, SharedSubscriber, Storage, StorageError};
68#[cfg(feature = "serde")]
69pub use shared::FileStorage;
70pub use store::{
71    catch_reduce, catch_reduce_panic, ReducePanic, ScopedStore, StateSubscriber, Store, StoreTask,
72    StoreTaskError,
73};
74pub use sub::Sub;
75pub use test_runtime::TestRuntime;
76pub use test_store::{ExhaustiveTestStore, TestStoreError};
77pub use test_support::{
78    allow_state_clones, on_state_clone, replay_snapshot, scoped_child_state, scoped_subscribe_state,
79    scoped_subscriber_next, shared_get, shared_with_mut, store_state, subscribe_state,
80    subscriber_wait_next,
81};
82
83pub use rust_key_paths;
84pub use key_paths_core;