pub struct VPath(/* private fields */);Expand description
A normalized, workspace-relative virtual path.
Implementations§
Source§impl VPath
impl VPath
Sourcepub fn parse(input: &str) -> Result<Self, VPathError>
pub fn parse(input: &str) -> Result<Self, VPathError>
Parse and normalize a portable virtual path.
Both slash styles are treated as separators so a path accepted on one host cannot become an escape on another. Parent components may simplify a path but may never escape the virtual root.
§Errors
Returns VPathError when the input is empty, absolute, contains a NUL byte or
platform prefix, or would escape the virtual root during normalization.
Sourcepub fn parent(&self) -> Option<Self>
pub fn parent(&self) -> Option<Self>
Return the normalized parent, or None for the virtual root.
Sourcepub fn file_name(&self) -> Option<&str>
pub fn file_name(&self) -> Option<&str>
Return the final path component, or None for the virtual root.
Sourcepub fn join(&self, child: &str) -> Result<Self, VPathError>
pub fn join(&self, child: &str) -> Result<Self, VPathError>
Join and normalize a relative child path.
§Errors
Returns VPathError if child is invalid or the combined path escapes the
virtual root.
Sourcepub fn is_within(&self, ancestor: &Self) -> bool
pub fn is_within(&self, ancestor: &Self) -> bool
Return whether this path is equal to or below ancestor.
Sourcepub fn relative_to<'a>(&'a self, ancestor: &Self) -> Option<&'a str>
pub fn relative_to<'a>(&'a self, ancestor: &Self) -> Option<&'a str>
Return the normalized relative suffix below ancestor.
Sourcepub fn rebase(&self, from: &Self, to: &Self) -> Result<Option<Self>, VPathError>
pub fn rebase(&self, from: &Self, to: &Self) -> Result<Option<Self>, VPathError>
Rebase this path from one virtual subtree to another.
§Errors
Returns VPathError if the rebased path would be invalid.