dartboard_local/store.rs
1use dartboard_core::Canvas;
2
3/// Persistence boundary for the canonical canvas. In-memory by default;
4/// the late-sh integration plan describes a postgres-backed impl.
5pub trait CanvasStore: Send + Sync {
6 /// Called on server startup. Return the canvas to initialize with, or
7 /// None for a fresh empty canvas.
8 fn load(&self) -> Option<Canvas>;
9
10 /// Called after every applied op. Implementations may debounce or skip.
11 fn save(&mut self, canvas: &Canvas);
12}
13
14#[derive(Default)]
15pub struct InMemStore;
16
17impl CanvasStore for InMemStore {
18 fn load(&self) -> Option<Canvas> {
19 None
20 }
21
22 fn save(&mut self, _canvas: &Canvas) {}
23}