1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! # eventfold
//!
//! Your application state is a fold over an event log.
//!
//! eventfold is a lightweight, append-only event log with derived views for Rust.
//! You define events as JSON, write pure reducer functions to fold them into state,
//! and let the library handle persistence, snapshots, and log rotation. No database,
//! no infrastructure — just files in a directory.
//!
//! ## Quick Start
//!
//! ```
//! # use tempfile::tempdir;
//! use eventfold::{Event, EventLog};
//! use serde::{Serialize, Deserialize};
//! use serde_json::json;
//!
//! #[derive(Default, Clone, Serialize, Deserialize)]
//! struct Counter { count: u64 }
//!
//! fn count_reducer(mut state: Counter, _event: &Event) -> Counter {
//! state.count += 1;
//! state
//! }
//!
//! # let dir = tempdir()?;
//! let mut log = EventLog::builder(dir.path())
//! .view::<Counter>("counter", count_reducer)
//! .open()?;
//!
//! log.append(&Event::new("click", json!({"x": 10})))?;
//! log.refresh_all()?;
//!
//! let state: &Counter = log.view("counter")?;
//! assert_eq!(state.count, 1);
//! # Ok::<(), std::io::Error>(())
//! ```
//!
//! ## Core Concepts
//!
//! - **Events** are immutable JSON records appended to a log file (`app.jsonl`).
//! - **Reducers** are pure functions `fn(State, &Event) -> State` that fold events
//! into application state.
//! - **Views** are derived state computed by applying a reducer to the event log,
//! with snapshots on disk for incremental performance.
//!
//! See `docs/guide.md` for a detailed concepts guide.
pub use Event;
pub use ;
pub use Snapshot;
pub use ;