wasmer_journal/concrete/
null.rs

1use super::*;
2
3pub static NULL_JOURNAL: NullJournal = NullJournal { debug_print: false };
4
5/// The null journal sends all the records into the abyss
6#[derive(Debug, Default)]
7pub struct NullJournal {
8    debug_print: bool,
9}
10
11impl ReadableJournal for NullJournal {
12    fn read(&self) -> anyhow::Result<Option<LogReadResult<'_>>> {
13        Ok(None)
14    }
15
16    fn as_restarted(&self) -> anyhow::Result<Box<DynReadableJournal>> {
17        Ok(Box::<NullJournal>::default())
18    }
19}
20
21impl WritableJournal for NullJournal {
22    fn write<'a>(&'a self, entry: JournalEntry<'a>) -> anyhow::Result<LogWriteResult> {
23        if self.debug_print {
24            tracing::debug!("journal event: {:?}", entry);
25        }
26        Ok(LogWriteResult {
27            record_start: 0,
28            record_end: entry.estimate_size() as u64,
29        })
30    }
31
32    fn flush(&self) -> anyhow::Result<()> {
33        Ok(())
34    }
35}
36
37impl Journal for NullJournal {
38    fn split(self) -> (Box<DynWritableJournal>, Box<DynReadableJournal>) {
39        (Box::<NullJournal>::default(), Box::<NullJournal>::default())
40    }
41}