VirtualPath

Enum VirtualPath 

Source
pub enum VirtualPath {
    Virtual {
        path: PathBuf,
        virtual_prefix: PathBuf,
        real_prefix: PathBuf,
    },
    Real(PathBuf),
}
Expand description

A container for WASI virtual paths that can also keep a reference to the original real path.

Variants§

§

Virtual

A virtual path with prefixes to determine a real path.

Fields

§path: PathBuf
§virtual_prefix: PathBuf
§real_prefix: PathBuf
§

Real(PathBuf)

Only a real path. Could not be matched with a virtual prefix.

Implementations§

Source§

impl VirtualPath

Source

pub fn exists(&self) -> bool

Inherited from Path::exists.

Source

pub fn has_root(&self) -> bool

Inherited from Path::has_root.

Source

pub fn is_absolute(&self) -> bool

Inherited from Path::is_absolute.

Source

pub fn is_dir(&self) -> bool

Inherited from Path::is_dir.

Source

pub fn is_file(&self) -> bool

Inherited from Path::is_file.

Source

pub fn is_relative(&self) -> bool

Inherited from Path::is_relative.

Source

pub fn extension(&self) -> Option<&OsStr>

Inherited from Path::extension.

Source

pub fn file_name(&self) -> Option<&OsStr>

Inherited from Path::file_name.

Source

pub fn file_stem(&self) -> Option<&OsStr>

Inherited from Path::file_stem.

Source

pub fn set_extension(&mut self, value: impl AsRef<OsStr>)

Inherited from PathBuf::set_extension.

Source

pub fn set_file_name(&mut self, value: impl AsRef<OsStr>)

Inherited from PathBuf::set_file_name.

Source

pub fn ends_with(&self, value: impl AsRef<Path>) -> bool

Inherited from Path::ends_with.

Source

pub fn starts_with(&self, value: impl AsRef<Path>) -> bool

Inherited from Path::starts_with.

Source

pub fn join<P>(&self, path: P) -> VirtualPath
where P: AsRef<Path>,

Append the path part and return a new VirtualPath instance.

Source

pub fn parent(&self) -> Option<VirtualPath>

Return the parent directory as a new VirtualPath instance.

Source

pub fn any_path(&self) -> &PathBuf

Return any path available, either virtual or real, regardless of any conditions. This is primarily used for debugging.

Source

pub fn real_path(&self) -> Option<PathBuf>

Return the original real path. If we don’t have access to prefixes, or removing prefix fails, returns None.

Source

pub fn real_path_string(&self) -> Option<String>

Return the original real path as a string.

Source

pub fn to_path_buf(&self) -> PathBuf

Convert the virtual path into a PathBuf instance. This does not convert it into a real path.

Source

pub fn virtual_path(&self) -> Option<PathBuf>

Return the virtual path. If a real path only, returns None.

Source

pub fn virtual_path_string(&self) -> Option<String>

Return the virtual path as a string.

Source

pub fn without_prefix(&self) -> Option<&Path>

Return the current path without a virtual prefix. If we don’t have access to prefixes, returns None.

Trait Implementations§

Source§

impl AsRef<OsStr> for VirtualPath

Source§

fn as_ref(&self) -> &OsStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Path> for VirtualPath

Source§

fn as_ref(&self) -> &Path

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<PathBuf> for VirtualPath

Source§

fn as_ref(&self) -> &PathBuf

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<VirtualPath> for VirtualPath

Source§

fn as_ref(&self) -> &VirtualPath

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for VirtualPath

Source§

fn clone(&self) -> VirtualPath

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtualPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for VirtualPath

Source§

fn default() -> VirtualPath

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for VirtualPath

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<VirtualPath, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for VirtualPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for VirtualPath

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for VirtualPath

Source§

fn eq(&self, other: &VirtualPath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for VirtualPath

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for VirtualPath

Source§

impl StructuralPartialEq for VirtualPath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,