tempest_core/journal/
config.rs1use std::io;
2
3use serde::{Serialize, de::DeserializeOwned};
4use smart_default::SmartDefault;
5
6use crate::utils::ByteSize;
7
8#[derive(Debug, Display, Error, From)]
9pub enum JournalError {
10 #[display("i/o error: {_0}")]
11 Io(io::Error),
12
13 #[display("encode error: {_0}")]
14 Encode(bincode::Error),
15
16 #[display("journal checksum mismatch: potential corruption")]
17 Checksum,
18
19 #[display("invalid magic number")]
20 InvalidMagic,
21
22 #[display("journal worker died")]
23 WorkerDied,
24}
25
26#[derive(Debug, Clone, SmartDefault)]
27#[debug("JournalConfig({:?} => {}x)", ByteSize(*growth_baseline), growth_factor)]
28pub struct JournalConfig {
29 #[default(2)]
30 pub growth_factor: u64,
31 #[default(64 * 1024 * 1024)]
32 pub growth_baseline: u64,
33}
34
35pub trait Replayable: 'static {
36 type Edit: Serialize + DeserializeOwned;
39
40 fn apply(&mut self, edit: Self::Edit);
42
43 fn snapshot(&self) -> Self::Edit;
46
47 fn filename_prefix() -> &'static str;
49
50 fn initial() -> Self;
53}