pub struct VirtualPath(/* private fields */);Expand description
An absolute path in the virtual file system of a project or package.
Implementations§
Source§impl VirtualPath
 
impl VirtualPath
Sourcepub fn new(path: impl AsRef<Path>) -> Self
 
pub fn new(path: impl AsRef<Path>) -> Self
Create a new virtual path.
Even if it doesn’t start with / or \, it is still interpreted as
starting from the root.
Sourcepub fn within_root(path: &Path, root: &Path) -> Option<Self>
 
pub fn within_root(path: &Path, root: &Path) -> Option<Self>
Create a virtual path from a real path and a real root.
Returns None if the file path is not contained in the root (i.e. if
root is not a lexical prefix of path). No file system operations are
performed.
Sourcepub fn as_rooted_path(&self) -> &Path
 
pub fn as_rooted_path(&self) -> &Path
Get the underlying path with a leading / or \.
Sourcepub fn as_rootless_path(&self) -> &Path
 
pub fn as_rootless_path(&self) -> &Path
Get the underlying path without a leading / or \.
Sourcepub fn resolve(&self, root: &Path) -> Option<PathBuf>
 
pub fn resolve(&self, root: &Path) -> Option<PathBuf>
Resolve the virtual path relative to an actual file system root (where the project or package resides).
Returns None if the path lexically escapes the root. The path might
still escape through symlinks.
Sourcepub fn join(&self, path: impl AsRef<Path>) -> Self
 
pub fn join(&self, path: impl AsRef<Path>) -> Self
Resolve a path relative to this virtual path.
Sourcepub fn with_extension(&self, extension: &str) -> Self
 
pub fn with_extension(&self, extension: &str) -> Self
The same path, but with a different extension.
Trait Implementations§
Source§impl Clone for VirtualPath
 
impl Clone for VirtualPath
Source§fn clone(&self) -> VirtualPath
 
fn clone(&self) -> VirtualPath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VirtualPath
 
impl Debug for VirtualPath
Source§impl Hash for VirtualPath
 
impl Hash for VirtualPath
Source§impl Ord for VirtualPath
 
impl Ord for VirtualPath
Source§fn cmp(&self, other: &VirtualPath) -> Ordering
 
fn cmp(&self, other: &VirtualPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
    Self: Sized,
 
fn max(self, other: Self) -> Selfwhere
    Self: Sized,
Source§impl PartialEq for VirtualPath
 
impl PartialEq for VirtualPath
Source§impl PartialOrd for VirtualPath
 
impl PartialOrd for VirtualPath
impl Eq for VirtualPath
impl StructuralPartialEq for VirtualPath
Auto Trait Implementations§
impl Freeze for VirtualPath
impl RefUnwindSafe for VirtualPath
impl Send for VirtualPath
impl Sync for VirtualPath
impl Unpin for VirtualPath
impl UnwindSafe for VirtualPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<Q, K> Comparable<K> for Q
 
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more