wasmer_journal/concrete/
boxed.rs

1use std::{ops::Deref, sync::Arc};
2
3use super::*;
4
5impl<R: ReadableJournal + ?Sized> ReadableJournal for Box<R> {
6    fn read(&self) -> anyhow::Result<Option<LogReadResult<'_>>> {
7        self.deref().read()
8    }
9
10    fn as_restarted(&self) -> anyhow::Result<Box<DynReadableJournal>> {
11        self.deref().as_restarted()
12    }
13}
14
15impl<W: WritableJournal + ?Sized> WritableJournal for Box<W> {
16    fn write<'a>(&'a self, entry: JournalEntry<'a>) -> anyhow::Result<LogWriteResult> {
17        self.deref().write(entry)
18    }
19
20    fn flush(&self) -> anyhow::Result<()> {
21        self.deref().flush()
22    }
23
24    fn commit(&self) -> anyhow::Result<usize> {
25        self.deref().commit()
26    }
27
28    fn rollback(&self) -> anyhow::Result<usize> {
29        self.deref().rollback()
30    }
31}
32
33impl Journal for Box<DynJournal> {
34    fn split(self) -> (Box<DynWritableJournal>, Box<DynReadableJournal>) {
35        let this = Arc::new(self);
36        (Box::new(this.clone()), Box::new(this))
37    }
38}