Path

Struct Path 

Source
pub struct Path { /* private fields */ }
Expand description

A borrowed reference to a subset of a path, e.g. another Path or a PathBuf

Implementations§

Source§

impl Path

Conversions

Source

pub const MAX_COMPONENT_LENGTH: usize = 255usize

Path components must be 255 bytes or less

Source

pub const EMPTY: &Path

An empty path for use as a default value, placeholder, comparisons, etc.

Source

pub const KERNEL_PATH: &str = "$kernel"

Base kernel path.

Source

pub const ABSOLUTE_KERNEL_PATH: &str = "::$kernel"

Source

pub const KERNEL: &Path

Source

pub const EXEC_PATH: &str = "$exec"

Path for an executable module.

Source

pub const ABSOLUTE_EXEC_PATH: &str = "::$exec"

Source

pub const EXEC: &Path

Source

pub fn new<S: AsRef<str> + ?Sized>(path: &S) -> &Path

Source

pub fn from_mut(path: &mut str) -> &mut Path

Source

pub fn validate(path: &str) -> Result<&Path, PathError>

Verify that path meets all the requirements for a valid Path

Source

pub const fn kernel_path() -> &'static Path

Get a Path corresponding to Self::KERNEL_PATH

Source

pub const fn exec_path() -> &'static Path

Get a Path corresponding to Self::EXEC_PATH

Source

pub const fn as_str(&self) -> &str

Source

pub fn as_mut_str(&mut self) -> &mut str

Source

pub fn as_ident(&self) -> Option<Ident>

Get an Ident that is equivalent to this Path, so long as the path has only a single component.

Returns None if the path cannot be losslessly represented as a single component.

Source

pub fn to_path_buf(&self) -> PathBuf

Convert this Path to an owned PathBuf

Source§

impl Path

Accesssors

Source

pub fn is_empty(&self) -> bool

Returns true if this path is empty (i.e. has no components)

Source

pub fn len(&self) -> usize

Returns the number of components in the path

Source

pub fn char_len(&self) -> usize

Return the size of the path in chars when displayed as a string

Source

pub fn byte_len(&self) -> usize

Return the size of the path in bytes when displayed as a string

Source

pub fn is_absolute(&self) -> bool

Returns true if this path is an absolute path

Source

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

Source

pub fn to_relative(&self) -> &Path

Strip the root prefix from this path, if it has one.

Source

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

Returns the Path without its final component, if there is one.

This means it may return an empty Path for relative paths with a single component.

Returns None if the path terminates with the root prefix, or if it is empty.

Source

pub fn components(&self) -> Iter<'_>

Returns an iterator over all components of the path.

Source

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.

Source

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.

Source

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

Source

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

Source

pub fn is_kernel_path(&self) -> bool

Returns true if this path is for the root kernel module.

Source

pub fn is_in_kernel(&self) -> bool

Returns true if this path is for the root kernel module or an item in it

Source

pub fn is_exec_path(&self) -> bool

Returns true if this path is for an executable module.

Source

pub fn starts_with<Prefix>(&self, prefix: &Prefix) -> bool
where Prefix: ?Sized, Self: StartsWith<Prefix>,

Returns true if the current path, sans root component, starts with prefix

Source

pub fn starts_with_exactly<Prefix>(&self, prefix: &Prefix) -> bool
where Prefix: ?Sized, Self: StartsWith<Prefix>,

Returns true if the current path, including root component, starts with prefix

Source

pub fn join(&self, path: impl AsRef<Path>) -> PathBuf

Create an owned PathBuf with path adjoined to self.

If path is absolute, it replaces the current path.

See PathBuf::push for more details on what it means to adjoin a path.

Trait Implementations§

Source§

impl<'a> AddAssign<&'a Path> for PathBuf

Source§

fn add_assign(&mut self, rhs: &'a Path)

Performs the += operation. Read more
Source§

impl AsRef<Path> for Ident

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<Path> for Path

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<Path> for PathBuf

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<Path> for ProcedureName

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<Path> for QualifiedProcedureName

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<Path> for str

Source§

fn as_ref(&self) -> &Path

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

impl AsRef<str> for Path

Source§

fn as_ref(&self) -> &str

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

impl Borrow<Path> for PathBuf

Source§

fn borrow(&self) -> &Path

Immutably borrows from an owned value. Read more
Source§

impl Debug for Path

Source§

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

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

impl Display for Path

Source§

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

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

impl From<&Path> for Arc<Path>

Source§

fn from(path: &Path) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Path> for PathBuf

Source§

fn from(path: &'a Path) -> Self

Converts to this type from the input type.
Source§

impl From<&Path> for QualifiedProcedureName

Source§

fn from(path: &Path) -> Self

Converts to this type from the input type.
Source§

impl Hash for Path

Source§

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

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

impl Ord for Path

Source§

fn cmp(&self, other: &Path) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq<&Path> for Path

Source§

fn eq(&self, other: &&Path) -> 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 PartialEq<&PathBuf> for Path

Source§

fn eq(&self, other: &&PathBuf) -> 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 PartialEq<Arc<Path>> for Path

Source§

fn eq(&self, other: &Arc<Path>) -> 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 PartialEq<Box<Path>> for Path

Source§

fn eq(&self, other: &Box<Path>) -> 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 PartialEq<Cow<'_, Path>> for Path

Source§

fn eq(&self, other: &Cow<'_, Path>) -> 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 PartialEq<Path> for PathBuf

Source§

fn eq(&self, other: &Path) -> 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 PartialEq<PathBuf> for Path

Source§

fn eq(&self, other: &PathBuf) -> 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 PartialEq<Rc<Path>> for Path

Source§

fn eq(&self, other: &Rc<Path>) -> 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 PartialEq<str> for Path

Source§

fn eq(&self, other: &str) -> 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 PartialEq for Path

Source§

fn eq(&self, other: &Path) -> 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 PartialOrd for Path

Source§

fn partial_cmp(&self, other: &Path) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serializable for Path

Source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
Source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
Source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
Source§

impl StartsWith<Path> for Path

Source§

fn starts_with(&self, prefix: &Path) -> bool

Returns true if the current path, sans root component, starts with prefix
Source§

fn starts_with_exactly(&self, prefix: &Path) -> bool

Returns true if the current path, including root component, starts with prefix
Source§

impl StartsWith<str> for Path

Source§

fn starts_with(&self, prefix: &str) -> bool

Returns true if the current path, sans root component, starts with prefix
Source§

fn starts_with_exactly(&self, prefix: &str) -> bool

Returns true if the current path, including root component, starts with prefix
Source§

impl ToOwned for Path

Source§

type Owned = PathBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> PathBuf

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

fn clone_into(&self, target: &mut Self::Owned)

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

impl Eq for Path

Source§

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Freeze for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl !Sized for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnwindSafe for Path

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more