pub struct VfsPath(_);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§
source§impl VfsPath
impl VfsPath
sourcepub 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 '/'.
sourcepub 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
sourcepub 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.
sourcepub fn join(&self, path: &str) -> Option<VfsPath>
pub fn join(&self, path: &str) -> Option<VfsPath>
Creates a new VfsPath with path adjoined to self.
sourcepub 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());sourcepub 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>
Trait Implementations§
source§impl From<AbsPathBuf> for VfsPath
impl From<AbsPathBuf> for VfsPath
source§fn from(v: AbsPathBuf) -> Self
fn from(v: AbsPathBuf) -> Self
Converts to this type from the input type.
source§impl Ord for VfsPath
impl Ord for VfsPath
source§impl PartialEq<VfsPath> for VfsPath
impl PartialEq<VfsPath> for VfsPath
source§impl PartialOrd<VfsPath> for VfsPath
impl PartialOrd<VfsPath> for VfsPath
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for VfsPath
impl StructuralEq for VfsPath
impl StructuralPartialEq for VfsPath
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.