pub struct VfsPath(VfsPathRepr);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.
Tuple Fields§
§0: VfsPathReprImplementations§
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.
pub fn into_abs_path(self) -> Option<AbsPathBuf>
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>
Sourcepub 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.
Sourcepub 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.
Sourcepub(crate) fn encode(&self, buf: &mut Vec<u8>)
pub(crate) fn encode(&self, buf: &mut Vec<u8>)
Don’t make this pub
Encode the path in the given buffer.
The encoding will be 0 if AbsPathBuf, 1 if VirtualPath, followed
by self’s representation.
Note that this encoding is dependent on the operating system.
Trait Implementations§
Source§impl From<AbsPathBuf> for VfsPath
impl From<AbsPathBuf> for VfsPath
Source§fn from(v: AbsPathBuf) -> Self
fn from(v: AbsPathBuf) -> Self
Source§impl Ord for VfsPath
impl Ord for VfsPath
Source§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 UnsafeUnpin 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
§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<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