Struct VfsPath
pub struct VfsPath(/* private fields */);Expand description
Path in Vfs.
Long-term, we want to support files which do not reside in the file-system,
so we treat VfsPaths as opaque identifiers.
Implementations§
§impl VfsPath
impl VfsPath
pub fn new_virtual_path(path: String) -> VfsPath
pub fn new_virtual_path(path: String) -> VfsPath
Creates an “in-memory” path from /-separated string.
This is most useful for testing, to avoid windows/linux differences
§Panics
Panics if path does not start with '/'.
pub fn new_real_path(path: String) -> VfsPath
pub fn new_real_path(path: String) -> VfsPath
Create a path from string. Input should be a string representation of an absolute path inside filesystem
pub fn as_path(&self) -> Option<&AbsPath>
pub fn as_path(&self) -> Option<&AbsPath>
Returns the AbsPath representation of self if self is on the file system.
pub fn into_abs_path(self) -> Option<AbsPathBuf>
pub fn pop(&mut self) -> bool
pub fn pop(&mut self) -> bool
Remove the last component of self if there is one.
If self has no component, returns false; else returns true.
§Example
let mut path = VfsPath::from(AbsPathBuf::assert("/foo/bar".into()));
assert!(path.pop());
assert_eq!(path, VfsPath::from(AbsPathBuf::assert("/foo".into())));
assert!(path.pop());
assert_eq!(path, VfsPath::from(AbsPathBuf::assert("/".into())));
assert!(!path.pop());pub fn starts_with(&self, other: &VfsPath) -> bool
pub fn starts_with(&self, other: &VfsPath) -> bool
Returns true if other is a prefix of self.
pub fn strip_prefix(&self, other: &VfsPath) -> Option<&RelPath>
pub fn parent(&self) -> Option<VfsPath>
pub fn parent(&self) -> Option<VfsPath>
Returns the VfsPath without its final component, if there is one.
Returns None if the path is a root or prefix.
pub fn name_and_extension(&self) -> Option<(&str, Option<&str>)>
pub fn name_and_extension(&self) -> Option<(&str, Option<&str>)>
Returns self’s base name and file extension.
Trait Implementations§
§impl Ord for VfsPath
impl Ord for VfsPath
§impl PartialOrd for VfsPath
impl PartialOrd for VfsPath
impl Eq for VfsPath
impl StructuralPartialEq for VfsPath
Auto Trait Implementations§
impl Freeze for VfsPath
impl RefUnwindSafe for VfsPath
impl Send for VfsPath
impl Sync for VfsPath
impl Unpin for VfsPath
impl UnwindSafe for VfsPath
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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