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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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