Skip to main content

PathLike

Trait PathLike 

Source
pub unsafe trait PathLike<'data>: Sized {
    // Required method
    fn into_path_bytes(self) -> Cow<'data, [u8]>;

    // Provided method
    fn into_path(self) -> Cow<'data, Path> { ... }
}
Expand description

A trait that represents a sequence of bytes that can be interpreted as a path. This is better than AsRef<Path> for the following reasons:

  • Doesn’t actually require Path or OsStr, thus working in #[no_std] environments
  • Preserves ownership, being closer to into Into<Cow> in this regard.

§Safety

Only implement this for types whose representation is the same as that of OsStr. Currently in the standard library those are str, OsStr & Path (and all their varieties)

Required Methods§

Source

fn into_path_bytes(self) -> Cow<'data, [u8]>

Convert this to a possibly owned sequence of bytes that’s guaranteed to uphold the same guarantees as an OsStr.

Provided Methods§

Source

fn into_path(self) -> Cow<'data, Path>

Available on crate feature std only.

Convert this to a possibly owned Path.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PathLike<'static> for Box<OsStr>

Source§

fn into_path_bytes(self) -> Cow<'static, [u8]>

Source§

impl PathLike<'static> for Box<Path>

Source§

fn into_path_bytes(self) -> Cow<'static, [u8]>

Source§

impl PathLike<'static> for Box<str>

Source§

fn into_path_bytes(self) -> Cow<'static, [u8]>

Source§

impl PathLike<'static> for OsString

Source§

fn into_path_bytes(self) -> Cow<'static, [u8]>

Source§

impl PathLike<'static> for PathBuf

Source§

fn into_path_bytes(self) -> Cow<'static, [u8]>

Source§

impl PathLike<'static> for String

Source§

fn into_path_bytes(self) -> Cow<'static, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Box<OsStr>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Box<Path>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Box<str>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Cow<'data, OsStr>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Cow<'data, Path>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Cow<'data, str>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data OsStr

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data OsString

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data Path

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data PathBuf

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data String

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for &'data str

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for Cow<'data, OsStr>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for Cow<'data, Path>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Source§

impl<'data> PathLike<'data> for Cow<'data, str>

Source§

fn into_path_bytes(self) -> Cow<'data, [u8]>

Implementors§