gglib_core/ports/settings_repository.rs
1//! Settings repository trait definition.
2//!
3//! This port defines the interface for application settings persistence.
4//! Implementations handle all storage details internally.
5
6use async_trait::async_trait;
7
8use super::RepositoryError;
9use crate::settings::Settings;
10
11/// Repository for application settings persistence.
12///
13/// This trait defines operations for storing and retrieving the application
14/// settings as a whole. The implementation handles serialization.
15///
16/// # Design Rules
17///
18/// - No `sqlx` types in signatures
19/// - Works with domain `Settings` type directly
20/// - Implementation handles JSON serialization internally
21#[async_trait]
22pub trait SettingsRepository: Send + Sync {
23 /// Load application settings.
24 ///
25 /// Returns default settings if none are stored.
26 async fn load(&self) -> Result<Settings, RepositoryError>;
27
28 /// Save application settings.
29 async fn save(&self, settings: &Settings) -> Result<(), RepositoryError>;
30}