#![allow( clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::cast_possible_wrap )] //! Repository trait definitions (pure — no impls, no concrete persistence). use std::path::Path; use crate::domain::oauth::OAuthToken; use crate::domain::session::Session; /// Repository for loading, saving, listing, and deleting sessions. pub trait SessionRepository { /// List all loadable sessions under `/sessions/`. fn list_sessions(&self, base_dir: &Path) -> anyhow::Result>; /// Load a single session by id. fn load_session(&self, base_dir: &Path, id: &str) -> anyhow::Result; /// Save a session's metadata to disk. fn save_session(&self, base_dir: &Path, session: &Session) -> anyhow::Result<()>; /// Delete a session directory and all its contents. fn delete_session(&self, base_dir: &Path, id: &str) -> anyhow::Result<()>; } /// Repository for per-session PID-file advisory locks. pub trait SessionLockRepository { /// Try to acquire the lock for a session directory. /// Returns `true` if the lock was acquired, `false` if another live /// process holds it. fn try_lock(&self, session_dir: &Path) -> anyhow::Result; /// Release the lock by removing the lock file. fn unlock(&self, session_dir: &Path) -> anyhow::Result<()>; /// Check whether a process with the given PID is alive. fn is_alive(&self, pid: u32) -> bool; } /// Repository for persisting and loading OAuth tokens. pub trait OAuthRepository { /// Persist an OAuth token to a JSON file. fn save_token(&self, path: &Path, token: &OAuthToken) -> anyhow::Result<()>; /// Load an OAuth token from a JSON file, returning `None` if the file /// does not exist. fn load_token(&self, path: &Path) -> anyhow::Result>; }