Struct Path
pub struct Path { /* private fields */ }Implementations§
§impl Path
Conversions
impl Path
Conversions
pub const MAX_COMPONENT_LENGTH: usize
pub const MAX_COMPONENT_LENGTH: usize
Path components must be 255 bytes or less
pub const EMPTY: &'static Path
pub const EMPTY: &'static Path
An empty path for use as a default value, placeholder, comparisons, etc.
pub const KERNEL_PATH: &'static str = "$kernel"
pub const KERNEL_PATH: &'static str = "$kernel"
Base kernel path.
pub const ABSOLUTE_KERNEL_PATH: &'static str = "::$kernel"
pub const KERNEL: &'static Path
pub const ABSOLUTE_EXEC_PATH: &'static str = "::$exec"
pub const EXEC: &'static Path
pub fn new<S>(path: &S) -> &Path
pub fn from_mut(path: &mut str) -> &mut Path
pub fn validate(path: &str) -> Result<&Path, PathError>
pub fn validate(path: &str) -> Result<&Path, PathError>
Verify that path meets all the requirements for a valid Path
pub const fn kernel_path() -> &'static Path
pub const fn kernel_path() -> &'static Path
Get a Path corresponding to Self::KERNEL_PATH
pub const fn exec_path() -> &'static Path
pub const fn exec_path() -> &'static Path
Get a Path corresponding to Self::EXEC_PATH
pub const fn as_str(&self) -> &str
pub fn as_mut_str(&mut self) -> &mut str
pub fn to_path_buf(&self) -> PathBuf
pub fn to_path_buf(&self) -> PathBuf
§impl Path
Accesssors
impl Path
Accesssors
pub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns true if this path is an absolute path
pub fn to_absolute(&self) -> Cow<'_, Path>
pub fn to_absolute(&self) -> Cow<'_, Path>
Make this path absolute, if not already
NOTE: This does not resolve the path, it simply ensures the path has the root prefix
pub fn to_relative(&self) -> &Path
pub fn to_relative(&self) -> &Path
Strip the root prefix from this path, if it has one.
pub fn components(&self) -> Iter<'_> ⓘ
pub fn components(&self) -> Iter<'_> ⓘ
Returns an iterator over all components of the path.
pub fn first(&self) -> Option<&str>
pub fn first(&self) -> Option<&str>
Get the first non-root component of this path as a str
Returns None if the path is empty, or consists only of the root prefix.
pub fn last(&self) -> Option<&str>
pub fn last(&self) -> Option<&str>
Get the first non-root component of this path as a str
Returns None if the path is empty, or consists only of the root prefix.
pub fn split_first(&self) -> Option<(&str, &Path)>
pub fn split_first(&self) -> Option<(&str, &Path)>
Splits this path on the first non-root component, returning it and a new Path of the remaining components.
Returns None if there are no components to split
pub fn split_last(&self) -> Option<(&str, &Path)>
pub fn split_last(&self) -> Option<(&str, &Path)>
Splits this path on the last component, returning it and a new Path of the remaining components.
Returns None if there are no components to split
pub fn is_kernel_path(&self) -> bool
pub fn is_kernel_path(&self) -> bool
Returns true if this path is for the root kernel module.
pub fn is_in_kernel(&self) -> bool
pub fn is_in_kernel(&self) -> bool
Returns true if this path is for the root kernel module or an item in it
pub fn is_exec_path(&self) -> bool
pub fn is_exec_path(&self) -> bool
Returns true if this path is for an executable module.
pub fn is_in_exec(&self) -> bool
pub fn is_in_exec(&self) -> bool
Returns true if this path is for the executable module or an item in it
pub fn starts_with<Prefix>(&self, prefix: &Prefix) -> bool
pub fn starts_with<Prefix>(&self, prefix: &Prefix) -> bool
Returns true if the current path, sans root component, starts with prefix
The matching semantics of Prefix depend on the implementation of StartsWith<Prefix>,
in particular, if Prefix is str, then the prefix is matched against the first non-root
component of self, regardless of whether the string contains path delimiters (i.e. ::).
See the StartsWith trait for more details.
pub fn starts_with_exactly<Prefix>(&self, prefix: &Prefix) -> bool
pub fn starts_with_exactly<Prefix>(&self, prefix: &Prefix) -> bool
Returns true if the current path, including root component, starts with prefix
The matching semantics of Prefix depend on the implementation of StartsWith<Prefix>,
in particular, if Prefix is str, then the prefix is matched against the first component
of self, regardless of whether the string contains path delimiters (i.e. ::).
See the StartsWith trait for more details.
pub fn strip_prefix<'a>(&'a self, prefix: &Path) -> Option<&'a Path>
pub fn strip_prefix<'a>(&'a self, prefix: &Path) -> Option<&'a Path>
Strips prefix from self, or returns None if self does not start with prefix.
NOTE: Prefixes must be exact, i.e. if you call path.strip_prefix(prefix) and path is
relative but prefix is absolute, then this will return None. The same is true if path
is absolute and prefix is relative.
pub fn join<P>(&self, other: &P) -> PathBuf
pub fn join<P>(&self, other: &P) -> PathBuf
Create an owned PathBuf with path adjoined to self.
If path is absolute, it replaces the current path.
The semantics of how other is joined to self in the resulting path depends on the
implementation of Join used. The implementation for Path and PathBuf joins all
components of other to self; while the implementation for [prim@str], string-like values, and identifiers/symbols joins just a single component. You must be careful to ensure that if you are passing a string here, that you specifically want to join it as a single component, or the resulting path may be different than you expect. It is recommended that you use Path::new(&string)` if you want to be explicit about treating a string-like value
as a multi-component path.
pub fn canonicalize(&self) -> Result<PathBuf, PathError>
pub fn canonicalize(&self) -> Result<PathBuf, PathError>
Canonicalize this path by ensuring that all components are in canonical form.
Canonical form dictates that:
- A component is quoted only if it requires quoting, and unquoted otherwise
- Is made absolute if relative and the first component is $kernel or $exec
Returns Err if the path is invalid
Trait Implementations§
§impl<'a> AddAssign<&'a Path> for PathBuf
impl<'a> AddAssign<&'a Path> for PathBuf
§fn add_assign(&mut self, rhs: &'a Path)
fn add_assign(&mut self, rhs: &'a Path)
+= operation. Read more§impl AsRef<Path> for ProcedureName
impl AsRef<Path> for ProcedureName
§impl AsRef<Path> for QualifiedProcedureName
impl AsRef<Path> for QualifiedProcedureName
§impl<'de> Deserialize<'de> for &'de Path
Available on crate feature serde only.
impl<'de> Deserialize<'de> for &'de Path
serde only.§fn deserialize<D>(
deserializer: D,
) -> Result<&'de Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<&'de Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl From<&Path> for QualifiedProcedureName
impl From<&Path> for QualifiedProcedureName
§fn from(path: &Path) -> QualifiedProcedureName
fn from(path: &Path) -> QualifiedProcedureName
§impl Join<ProcedureName> for Path
impl Join<ProcedureName> for Path
§impl Join<QualifiedProcedureName> for Path
impl Join<QualifiedProcedureName> for Path
§impl PartialOrd for Path
impl PartialOrd for Path
§impl Serializable for Path
impl Serializable for Path
§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
self into bytes and writes these bytes into the target.§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
§impl Serialize for Path
Available on crate feature serde only.
impl Serialize for Path
serde only.§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
§impl StartsWith<Path> for Path
impl StartsWith<Path> for Path
§fn starts_with(&self, prefix: &Path) -> bool
fn starts_with(&self, prefix: &Path) -> bool
prefix§fn starts_with_exactly(&self, prefix: &Path) -> bool
fn starts_with_exactly(&self, prefix: &Path) -> bool
prefix§impl StartsWith<str> for Path
impl StartsWith<str> for Path
§fn starts_with(&self, prefix: &str) -> bool
fn starts_with(&self, prefix: &str) -> bool
prefix§fn starts_with_exactly(&self, prefix: &str) -> bool
fn starts_with_exactly(&self, prefix: &str) -> bool
prefix