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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Append-only event journal trait for deterministic replay.
//!
//! The [`Journal`] trait defines the contract for persisting
//! [`SequencerEvent`] instances to durable
//! storage. Implementations must guarantee write-ahead semantics: an event
//! is considered committed only after [`append`](Journal::append) returns
//! `Ok(())`.
//!
//! See `FileJournal` (in the `file_journal` module) for the default
//! memory-mapped file implementation.
use JournalError;
use SequencerEvent;
use ;
/// Size of the fixed-size entry header in bytes.
///
/// Layout: `[4 bytes entry_length][8 bytes sequence_num][8 bytes timestamp_ns]`
pub const ENTRY_HEADER_SIZE: usize = 4 + 8 + 8;
/// Size of the CRC32 trailer appended to each entry in bytes.
pub const ENTRY_CRC_SIZE: usize = 4;
/// Total overhead per journal entry (header + CRC trailer) in bytes.
pub const ENTRY_OVERHEAD: usize = ENTRY_HEADER_SIZE + ENTRY_CRC_SIZE;
/// A single journal entry as read back from storage.
///
/// Contains the deserialized event together with its on-disk metadata.
/// Type alias for the iterator returned by [`Journal::read_from`].
///
/// Each item is either a successfully decoded [`JournalEntry`] or a
/// [`JournalError`] (e.g. corrupt CRC, deserialization failure).
pub type JournalReadIter<T> = ;
/// An append-only event journal for deterministic replay.
///
/// Implementations must provide durable, ordered storage of
/// [`SequencerEvent`] instances. The journal is the foundation of the
/// write-ahead log pattern: every event must be persisted before its
/// result is returned to the caller.
///
/// # Type Parameters
///
/// * `T` — the extra-fields type carried by `OrderType<T>`. Must be
/// serializable and deserializable for journal persistence.
///
/// # Thread Safety
///
/// The trait requires `Send + Sync` so the journal can be shared across
/// async task boundaries. However, the intended usage pattern is
/// single-writer (the Sequencer thread) with concurrent readers (replay,
/// monitoring).