Skip to main content

act_credentials/backend/
mod.rs

1use std::path::{Path, PathBuf};
2
3pub mod file;
4
5use crate::store::{CredentialStore, StoreError};
6
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum BackendChoice {
9    File(PathBuf),
10}
11
12/// The file store is the only backend. Its contents are plaintext on disk,
13/// protected by filesystem permissions alone — nothing here encrypts them.
14///
15/// Selection still goes through this seam, and the choice is still explicit,
16/// so a second backend can arrive as another `BackendChoice` variant rather
17/// than being wired in somewhere else. `state_dir` is the host's own state
18/// directory, unused while `File` carries its own root.
19pub fn select(
20    choice: BackendChoice,
21    _state_dir: &Path,
22) -> Result<Box<dyn CredentialStore>, StoreError> {
23    match choice {
24        BackendChoice::File(root) => Ok(Box::new(file::FileStore::new(root))),
25    }
26}