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
//! # Rabia Persistence
//!
//! Simple persistence implementations for the Rabia consensus protocol.
//!
//! This crate provides simplified persistence implementations that store
//! exactly one state value, matching Rabia's consensus requirements.
//!
//! ## Implementations
//!
//! - [`InMemoryPersistence`] - State stored in memory (testing/non-persistent)
//! - [`FileSystemPersistence`] - State stored in a file (persistent across restarts)
//!
//! ## Example
//!
//! ```rust
//! use rabia_persistence::{InMemoryPersistence, FileSystemPersistence};
//! use rabia_core::persistence::PersistenceLayer;
//!
//! # tokio_test::block_on(async {
//! // In-memory persistence
//! let persistence = InMemoryPersistence::new();
//! persistence.save_state(b"hello world").await.unwrap();
//! let state = persistence.load_state().await.unwrap();
//! assert_eq!(state, Some(b"hello world".to_vec()));
//!
//! // File-based persistence
//! let fs_persistence = FileSystemPersistence::new("/tmp/rabia-test").await.unwrap();
//! fs_persistence.save_state(b"persistent state").await.unwrap();
//! let state = fs_persistence.load_state().await.unwrap();
//! assert_eq!(state, Some(b"persistent state".to_vec()));
//! # });
//! ```
pub use FileSystemPersistence;
pub use InMemoryPersistence;