//! SQLite adapter for transcode settings (TranscodeSettingsRepository). use async_trait::async_trait; use sqlx::SqlitePool; use domain::{ ports::transcode::TranscodeSettingsRepository, DomainError, DomainResult, }; pub struct SqliteTranscodeSettings { pool: SqlitePool, } impl SqliteTranscodeSettings { pub fn new(pool: SqlitePool) -> Self { Self { pool } } } #[async_trait] impl TranscodeSettingsRepository for SqliteTranscodeSettings { async fn load_cleanup_ttl(&self) -> DomainResult> { let row: Option<(i64,)> = sqlx::query_as("SELECT cleanup_ttl_hours FROM transcode_settings WHERE id = 1") .fetch_optional(&self.pool) .await .map_err(|e| DomainError::InfrastructureError(e.to_string()))?; Ok(row.map(|(h,)| h as u32)) } async fn save_cleanup_ttl(&self, hours: u32) -> DomainResult<()> { sqlx::query("UPDATE transcode_settings SET cleanup_ttl_hours = ? WHERE id = 1") .bind(hours as i64) .execute(&self.pool) .await .map_err(|e| DomainError::InfrastructureError(e.to_string()))?; Ok(()) } }