pub struct Path { /* private fields */ }Expand description
A validated logical path independent of any provider-native representation.
§Examples
use qubit_fs::Path;
use qubit_fs::path::RelativePath;
let root = Path::parse("/reports")?;
let report = root.join(&RelativePath::parse("daily.csv")?);
assert_eq!("/reports/daily.csv", report.as_str());
assert!(report.is_absolute());Implementations§
Source§impl Path
impl Path
Sourcepub fn from_components<I, S>(absolute: bool, components: I) -> FsResult<Self>
pub fn from_components<I, S>(absolute: bool, components: I) -> FsResult<Self>
Constructs a hierarchical path from independently validated components.
Each item is validated as one component without reparsing a joined path string. An empty absolute sequence produces the root; an empty relative sequence returns an invalid-path error.
§Parameters
absolute: Whether the resulting path is rooted at the provider root.components: Validated path-component text to join in order.
§Errors
Returns an invalid-path error when a component is empty, contains a separator or traversal marker, or when a relative sequence is empty.
Sourcepub fn parse_literal(text: &str) -> FsResult<Self>
pub fn parse_literal(text: &str) -> FsResult<Self>
Sourcepub fn parse_with_semantics(
text: &str,
semantics: PathSemantics,
) -> FsResult<Self>
pub fn parse_with_semantics( text: &str, semantics: PathSemantics, ) -> FsResult<Self>
Parses text according to explicitly selected provider semantics.
Hierarchical values normalize empty and dot components and reject root escapes. Object-key and provider-specific values preserve their text.
§Parameters
text: Provider path text to validate and normalize.semantics: Path semantics controlling normalization and root rules.
§Errors
Returns an invalid-path error when text is empty, contains NUL, or
escapes above the hierarchical root.
Sourcepub fn file_name(&self) -> Option<&str>
pub fn file_name(&self) -> Option<&str>
Returns the final non-empty path component, when one is present.
A root path and a literal path ending in a separator have no file name. Hierarchical paths are canonicalized during parsing, so their final component is always non-empty.
§Returns
Some with the final non-empty component, or None for a root or a
literal path ending in a separator.
Sourcepub const fn is_absolute(&self) -> bool
pub const fn is_absolute(&self) -> bool
Returns whether this path is absolute.
Sourcepub const fn semantics(&self) -> PathSemantics
pub const fn semantics(&self) -> PathSemantics
Returns the semantics used to validate this logical path.
Sourcepub fn components(&self) -> PathComponents<'_> ⓘ
pub fn components(&self) -> PathComponents<'_> ⓘ
Iterates lexical component boundaries without using an empty root value.
Sourcepub fn child(&self, component: &PathComponent) -> Self
pub fn child(&self, component: &PathComponent) -> Self
Appends one validated component without re-parsing provider text.
Sourcepub fn join(&self, relative: &RelativePath) -> Self
pub fn join(&self, relative: &RelativePath) -> Self
Appends a safe normalized relative path without re-parsing provider text.