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.
§Type Parameters
I: Iterator type yielding the component values.S: Component value type borrowing string slices throughAsRef.
§Parameters
absolute: Whether the resulting path is rooted at the provider root.components: Validated path-component text to join in order.
§Returns
Returns the validated path containing the joined components.
§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(text: &str) -> FsResult<Self>
pub fn parse(text: &str) -> FsResult<Self>
Parses a hierarchical logical path using normalized semantics.
Returns an invalid-path error for empty input, NUL, or root escape.
§Errors
Returns FsError with an invalid-path kind when text is empty,
contains NUL, or escapes above the hierarchical root.
§Parameters
text: Hierarchical path spelling to normalize and validate.
§Returns
Returns the normalized hierarchical path.
Sourcepub fn parse_literal(text: &str) -> FsResult<Self>
pub fn parse_literal(text: &str) -> FsResult<Self>
Parses a provider-literal path without interpreting separators or dots.
Returns an invalid-path error for empty input or NUL.
§Errors
Returns FsError with an invalid-path kind when text is empty or
contains NUL.
§Parameters
text: Provider-literal path spelling to retain and validate.
§Returns
Returns the provider-literal path preserving text.
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.
§Returns
Returns the path using the selected provider semantics.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the validated logical path text.
§Returns
Returns the canonical or provider-literal spelling borrowed from this path.
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.
§Returns
Returns true when this path starts at a provider root.
Sourcepub const fn semantics(&self) -> PathSemantics
pub const fn semantics(&self) -> PathSemantics
Returns the semantics used to validate this logical path.
§Returns
Returns the semantics selected when this path was parsed or constructed.
Sourcepub fn components(&self) -> PathComponents<'_> ⓘ
pub fn components(&self) -> PathComponents<'_> ⓘ
Iterates lexical component boundaries without using an empty root value.
§Returns
Returns an iterator over lexical components; literal paths preserve empty components between separators.