pub struct ProjectPaths { /* private fields */ }Expand description
A validated read-only dictionary of project-wide named filesystem paths.
Cloning this type clones only an Arc. The project root, exact source
bytes, declaration-ordered entries, and lookup index remain in one shared
immutable allocation.
Implementations§
Source§impl ProjectPaths
impl ProjectPaths
Sourcepub fn load(
project_root: impl Into<PathBuf>,
) -> Result<Self, ConfigurationError>
pub fn load( project_root: impl Into<PathBuf>, ) -> Result<Self, ConfigurationError>
Loads the standard config/paths.json beneath project_root.
project_root is retained exactly as supplied. Relative configured paths
are later joined to it lexically; neither the root nor configured values
are canonicalized.
§Errors
Returns contextual file or JSON errors, recursive duplicate-key errors,
or ConfigurationError::InvalidConfigurationDocument when the root is
not an object or a key has a non-string or empty path value.
Sourcepub fn project_root(&self) -> &Path
pub fn project_root(&self) -> &Path
Returns the project root exactly as supplied at load time.
Sourcepub fn source_path(&self) -> &Path
pub fn source_path(&self) -> &Path
Returns the derived config/paths.json source path.
Sourcepub fn source_json(&self) -> &[u8] ⓘ
pub fn source_json(&self) -> &[u8] ⓘ
Borrows the validated original bytes of paths.json unchanged.
The slice preserves whitespace, declaration order, escaping, and every other byte-level source detail.
Sourcepub fn contains(&self, key: &str) -> bool
pub fn contains(&self, key: &str) -> bool
Reports whether an exact, case-sensitive path key is declared.
Sourcepub fn path(&self, key: &str) -> Option<&Path>
pub fn path(&self, key: &str) -> Option<&Path>
Borrows one configured path exactly as represented by its JSON string.
Relative values remain relative. Missing keys return None; no
filesystem operation or allocation occurs.
Sourcepub fn require_path(&self, key: &str) -> Result<&Path, ConfigurationError>
pub fn require_path(&self, key: &str) -> Result<&Path, ConfigurationError>
Borrows one required configured path or returns its exact missing key.
Sourcepub fn resolve_path(&self, key: &str) -> Result<PathBuf, ConfigurationError>
pub fn resolve_path(&self, key: &str) -> Result<PathBuf, ConfigurationError>
Returns one path resolved lexically against the project root.
Absolute configured paths are returned unchanged. Relative paths are
joined with ProjectPaths::project_root. The result is not
canonicalized, normalized, opened, or checked for existence.
Sourcepub fn keys(&self) -> impl ExactSizeIterator<Item = &str>
pub fn keys(&self) -> impl ExactSizeIterator<Item = &str>
Iterates exact path keys in JSON declaration order.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (&str, &Path)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (&str, &Path)>
Iterates declaration-ordered exact keys and unresolved path values.
Trait Implementations§
Source§impl Clone for ProjectPaths
impl Clone for ProjectPaths
Source§fn clone(&self) -> ProjectPaths
fn clone(&self) -> ProjectPaths
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more