pub struct AppDirectories {
pub extensions_dir: PathBuf,
pub storage_dir: PathBuf,
pub logs_dir: PathBuf,
}Expand description
Re-export of AppDirectories — platform-aware directory resolution.
See AppDirectories::resolve for the full resolution logic including
environment variable overrides and user configuration files.
Application directories derived from configuration.
AppDirectories holds the resolved filesystem paths that DSCode uses to
store extensions, persistent data, and log files. Paths are resolved at
construction time from a priority chain of environment variables, user
configuration, and platform defaults.
§Resolution priority (highest to lowest)
- Environment variable override — e.g.
DSCODE_EXTENSIONS_DIRfor the extensions directory. - User config file —
~/.dscode/config.json, which may specify custom paths under a"paths"object. - Platform default —
~/.dscode/extensions,~/.dscode/storage, and~/.dscode/logsrespectively.
§User Configuration
Reads ~/.dscode/config.json for custom paths:
{
"paths": {
"extensionsDir": "/custom/extensions",
"storageDir": "/custom/storage",
"logsDir": "/custom/logs"
}
}Both camelCase and snake_case keys are accepted.
§Invariants
- All three directory paths exist on disk after
AppDirectories::resolvereturnsOk. Directories are created automatically if they do not exist. - Tilde (
~) prefixes in user-configured paths are expanded to the home directory. - Paths are canonicalised when possible; if canonicalisation fails (e.g. the path does not yet exist on some platforms), the original path is kept unchanged.
Fields§
§extensions_dir: PathBufDirectory where installed extensions are stored.
Can be overridden by the DSCODE_EXTENSIONS_DIR environment variable.
storage_dir: PathBufDirectory for persistent application storage (e.g. workspace state, user preferences).
logs_dir: PathBufDirectory where log files are written.
Implementations§
Source§impl AppDirectories
impl AppDirectories
Sourcepub fn resolve() -> Result<Self, String>
pub fn resolve() -> Result<Self, String>
Resolve directories from user configuration and environment overrides.
The method applies the priority chain (environment variable > user
config > platform default) for each of the three directory paths,
expands ~ prefixes, creates directories that do not yet exist, and
canonicalises the resulting paths.
§Errors
Returns Err(String) if:
- A
~path cannot be expanded because the home directory is unavailable. - A directory cannot be created due to a filesystem permission error.
§Example
use dscode_core::AppDirectories;
let dirs = AppDirectories::resolve().expect("failed to resolve dirs");
println!("Extensions: {:?}", dirs.extensions_dir);Trait Implementations§
Source§impl Clone for AppDirectories
impl Clone for AppDirectories
Source§fn clone(&self) -> AppDirectories
fn clone(&self) -> AppDirectories
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more