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 VfsPath
s as opaque identifiers.
Implementations
sourceimpl 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
.
Trait Implementations
sourceimpl From<AbsPathBuf> for VfsPath
impl From<AbsPathBuf> for VfsPath
sourcefn from(v: AbsPathBuf) -> Self
fn from(v: AbsPathBuf) -> Self
Converts to this type from the input type.
sourceimpl Ord for VfsPath
impl Ord for VfsPath
sourceimpl PartialOrd<VfsPath> for VfsPath
impl PartialOrd<VfsPath> for VfsPath
sourcefn partial_cmp(&self, other: &VfsPath) -> Option<Ordering>
fn partial_cmp(&self, other: &VfsPath) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more