storage

Storage-related configuration (data directory resolution).

struct Settings

source

pub struct Settings

Storage-related configuration settings.

Controls where gest persists data on disk. The [storage] TOML table maps to this struct.

Field Type Description
cache_dir Option<PathBuf> Explicit cache directory override from the config file.
data_dir Option<PathBuf> Explicit data directory override from the config file.
sync Option<bool> Whether automatic file sync with .gest/ directories is enabled. Defaults to true when absent.

Implements Clone, Debug, Default, Deserialize<'de>, PartialEq, Serialize.

Settings::cache_dir

source

pub fn cache_dir(&self) -> Result<PathBuf, Error>

Resolves the cache directory using the following precedence:

  1. GEST_STORAGE__CACHE_DIR environment variable (must be absolute)
  2. storage.cache_dir from the config file (must be absolute)
  3. XDG cache home ($XDG_CACHE_HOME/gest), falling back to ~/.cache/gest when XDG_CACHE_HOME is unset (handled by dir_spec::cache_home).

The cache directory holds regeneratable artifacts (such as the avatar cache) that gest owns internally. Users control only the root; layout beneath it is an implementation detail.

Parameter Type Description
returns Result<PathBuf, Error> The cache directory, or Error::XDGDirNotFound when no override applies and the XDG cache directory cannot be resolved.

Settings::data_dir

source

pub fn data_dir(&self) -> Result<PathBuf, Error>

Resolves the data directory using the following precedence:

  1. GEST_STORAGE__DATA_DIR environment variable (must be absolute)
  2. storage.data_dir from the config file (must be absolute)
  3. XDG data home ($XDG_DATA_HOME/gest)
Parameter Type Description
returns Result<PathBuf, Error> The data directory, or Error::XDGDirNotFound when no override applies and the XDG data directory cannot be resolved.

Settings::data_dir_override

source

pub fn data_dir_override(&self) -> Option<PathBuf>

Resolve only an explicit data-dir override, without falling back to XDG.

Returns None when neither environment nor config supplies a usable absolute data directory. This lets startup distinguish “user explicitly asked for this database root” from the default global fallback.

Parameter Type Description
returns Option<PathBuf> The absolute override from the environment or the config file.

Settings::sync_enabled

source

pub fn sync_enabled(&self) -> bool

Whether automatic file sync with .gest/ directories is enabled.

Precedence:

  1. GEST_STORAGE__SYNC environment variable (boolean)
  2. storage.sync from the config file
  3. Defaults to true
Parameter Type Description
returns bool The first value set, in the order above.