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
use crate::{game::AnkiDB, storage::Storage};
#[derive(Default)]
pub struct DummyStorage(AnkiDB);
impl Storage for DummyStorage {
type ErrorType = ();
fn read_db(&self) -> Result<AnkiDB, Self::ErrorType> {
Ok(self.0.clone())
}
fn write_db(&mut self, db: &AnkiDB) -> Result<(), Self::ErrorType> {
self.0 = db.clone();
Ok(())
}
}
pub trait DynStorage<E: std::fmt::Debug> {
fn read_custom(&mut self, s: &dyn Storage<ErrorType = E>) -> Result<(), E>;
fn write_custom(&mut self, s: &mut dyn Storage<ErrorType = E>) -> Result<(), E>;
fn exit_custom(&mut self, s: &mut dyn Storage<ErrorType = E>);
}