Skip to main content

Pather

Trait Pather 

Source
pub trait Pather: Send + Sync {
    // Required methods
    fn home_dir(&self) -> &Path;
    fn dotfiles_root(&self) -> &Path;
    fn data_dir(&self) -> &Path;
    fn config_dir(&self) -> &Path;
    fn cache_dir(&self) -> &Path;
    fn xdg_config_home(&self) -> &Path;
    fn shell_dir(&self) -> &Path;

    // Provided methods
    fn pack_path(&self, pack: &str) -> PathBuf { ... }
    fn pack_data_dir(&self, pack: &str) -> PathBuf { ... }
    fn handler_data_dir(&self, pack: &str, handler: &str) -> PathBuf { ... }
    fn init_script_path(&self) -> PathBuf { ... }
}
Expand description

Provides all path calculations for dodot.

Every path that dodot uses – XDG directories, pack locations, handler data directories – is computed through this trait. This keeps path logic centralised and makes testing straightforward: construct a Pather whose directories all live under a temp dir.

Use &dyn Pather (trait objects) throughout the codebase.

Required Methods§

Source

fn home_dir(&self) -> &Path

The user’s home directory (e.g. /home/alice).

Source

fn dotfiles_root(&self) -> &Path

Root of the dotfiles repository.

Source

fn data_dir(&self) -> &Path

XDG data directory for dodot (e.g. ~/.local/share/dodot).

Source

fn config_dir(&self) -> &Path

XDG config directory for dodot (e.g. ~/.config/dodot).

Source

fn cache_dir(&self) -> &Path

XDG cache directory for dodot (e.g. ~/.cache/dodot).

Source

fn xdg_config_home(&self) -> &Path

XDG config home (e.g. ~/.config). Used by symlink handler for subdirectory target mapping.

Source

fn shell_dir(&self) -> &Path

Shell scripts directory (e.g. ~/.local/share/dodot/shell).

Provided Methods§

Source

fn pack_path(&self, pack: &str) -> PathBuf

Absolute path to a pack’s source directory.

Source

fn pack_data_dir(&self, pack: &str) -> PathBuf

Data directory for a specific pack (e.g. .../data/packs/{pack}).

Source

fn handler_data_dir(&self, pack: &str, handler: &str) -> PathBuf

Data directory for a specific handler within a pack (e.g. .../data/packs/{pack}/{handler}).

Source

fn init_script_path(&self) -> PathBuf

Path to the generated shell init script.

Implementors§