pub struct Paths {
pub data_dir: PathBuf,
pub config_dir: PathBuf,
pub config_file: PathBuf,
pub state_dir: PathBuf,
}Expand description
XDG-compliant paths for rec data, config, and state.
On Linux, uses the XDG Base Directory Specification:
- Data: ~/.local/share/rec/sessions/
- Config: ~/.config/rec/config.toml
- State: ~/.local/state/rec/ (or ~/.local/share/rec/state)
If XDG directories are unavailable (ProjectDirs returns None),
falls back to ~/.rec for all paths.
Fields§
§data_dir: PathBufDirectory for session data files
config_dir: PathBufDirectory for configuration files
config_file: PathBufPath to the main config file
state_dir: PathBufDirectory for state files (recording state, PID files)
Implementations§
Source§impl Paths
impl Paths
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new Paths using XDG directories with ~/.rec fallback.
Attempts to use the XDG Base Directory Specification via the
directories crate. If that fails (e.g., on systems without
proper XDG support), falls back to ~/.rec for all paths.
§Panics
Panics if the home directory cannot be determined (XDG fallback path).
Sourcepub fn ensure_dirs(&self) -> Result<()>
pub fn ensure_dirs(&self) -> Result<()>
Ensure all directories exist, creating them if necessary.
Creates:
data_dir(for session files)config_dir(for config.toml)state_dir(for recording state)
§Errors
Returns an error if directory creation fails (e.g., permission denied).
Sourcepub fn session_file(&self, id: &str) -> PathBuf
pub fn session_file(&self, id: &str) -> PathBuf
Get the path for a session file by ID.
Session files use the .ndjson extension for NDJSON format.
Sourcepub fn backup_file(&self, id: &str) -> PathBuf
pub fn backup_file(&self, id: &str) -> PathBuf
Get the path for a session backup file by ID.
Backup files use the .ndjson.bak extension and are created
before modifying session data (rename, tag, etc.) to allow
recovery if the modification fails.