Skip to main content

superstac_core/models/
storage.rs

1use crate::storages::{factory::StorageBackend, memory::MemoryStorage};
2use serde::{Deserialize, Serialize};
3
4/// Backend selector. SQLite and Postgres variants currently fall back to
5/// the in-memory backend — they're placeholders for future work.
6#[derive(Clone, Debug, Serialize, Deserialize)]
7pub enum Storage {
8    Memory,
9    Sqlite(String),
10    Postgres(String),
11}
12
13impl Storage {
14    /// Construct an empty backend. Config loaders (e.g. YAML) call this and
15    /// then populate the returned backend.
16    pub fn init(self) -> Box<dyn StorageBackend> {
17        match self {
18            Storage::Memory => Box::new(MemoryStorage::init()),
19            Storage::Sqlite(_path) => Box::new(MemoryStorage::init()),
20            Storage::Postgres(_url) => Box::new(MemoryStorage::init()),
21        }
22    }
23}