rustriff_lib/infrastructure/persistence/amp_config_persistence_trait.rs
1use crate::domain::dto::amp_config_dto::AmpConfigDto;
2
3/// Backend abstraction for amplifier configuration persistence.
4///
5/// This trait isolates the rest of the application from the concrete storage
6/// mechanism.
7///
8/// Implementations are expected to:
9/// - return `Ok(None)` when no persisted config exists yet,
10/// - return `Err(String)` when the data exists but cannot be read or parsed,
11/// - persist a full amplifier snapshot on `save`.
12pub trait AmpConfigPersistence: Send + Sync {
13 /// Loads the most recently persisted amplifier configuration.
14 ///
15 /// Returns `Ok(None)` when no stored configuration is available yet.
16 fn load(&self) -> Result<Option<AmpConfigDto>, String>;
17
18 /// Persists the supplied amplifier configuration snapshot.
19 ///
20 /// Implementations should overwrite the previous snapshot atomically from
21 /// the application's point of view: after a successful return, the new
22 /// state is considered the canonical persisted config.
23 fn save(&self, config: &AmpConfigDto) -> Result<(), String>;
24}