pub enum WinPathKind {
    Drive(u16),
    Unc,
    Device,
    CurrentDirectoryRelative,
    Verbatim,
    DriveRelative(u16),
    RootRelative,
}
Expand description

Windows path type.

This does not do any validation so parsing the kind will never fail, even for broken or invalid paths.

Variants§

§

Drive(u16)

A traditional drive path such as C:\, R:\, etc.

§

Unc

A path to a network directory such as \\server\share\.

§

Device

A device path such as \\.\COM1.

§

CurrentDirectoryRelative

A path that’s relative to the current directory.

§

Verbatim

A path that is passed to the NT kernel without parsing, except to change the prefix.

These start with \\?\, avoid DOS path length limits and can contain paths that are otherwise illegal.

§

DriveRelative(u16)

A DOS drive relative path (e.g. C:file).

§

RootRelative

A DOS root relative path (e.g. \file).

Note that some Windows APIs can return paths that are relative to a specified drive. These may start with a \ but should be joined to the drive path instead of being treated like a DOS RootRelative path.

Implementations§

source§

impl WinPathKind

source

pub const fn split_str(path: &str) -> (Self, &str)

Split the path into WinPathKind and the rest of the path.

Note that this only splits off the smallest part needed to identify the path type. E.g. the UNC path \\server\share\file.txt will be split as (WinPathKind::Unc, "server\share\file.txt").

source

pub const fn from_str(path: &str) -> Self

Examine the path prefix to find the type of the path given.

source

pub const fn is_absolute(self) -> bool

Is the path absolute. Being absolute means it doesn’t need to be joined to a base path (e.g. the current directory, or a drive current directory)

source

pub const fn as_relative(self) -> Option<Win32Relative>

Returns the relative path kind or None for absolute paths.

source

pub const fn is_legacy_relative(self) -> bool

Is the path one of the weird ones from DOS.

These should probably be considered invalid if given from a configuration file but you may want to support them if given through command line arguments (e.g. because they come from the command prompt or a bat file).

source

pub const fn utf16_len(self) -> usize

The number of UTF-16 code units that make up the path kind.

source

pub const fn utf8_len(self) -> usize

The number of UTF-8 code units that make up the path kind.

Trait Implementations§

source§

impl Clone for WinPathKind

source§

fn clone(&self) -> WinPathKind

Returns a copy 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 WinPathKind

source§

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

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

impl PartialEq<WinPathKind> for WinPathKind

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for WinPathKind

source§

impl Eq for WinPathKind

source§

impl StructuralEq for WinPathKind

source§

impl StructuralPartialEq for WinPathKind

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.