Struct camino::FromPathBufError[][src]

pub struct FromPathBufError { /* fields omitted */ }

A possible error value while converting a PathBuf to a Utf8PathBuf.

Produced by the TryFrom<PathBuf> implementation for Utf8PathBuf.

Examples

use camino::{Utf8PathBuf, FromPathBufError};
use std::convert::{TryFrom, TryInto};
use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
use std::path::PathBuf;

let unicode_path = PathBuf::from("/valid/unicode");
let utf8_path_buf: Utf8PathBuf = unicode_path.try_into().expect("valid Unicode path succeeded");

// Paths on Unix can be non-UTF-8.
let non_unicode_str = OsStr::from_bytes(b"\xFF\xFF\xFF");
let non_unicode_path = PathBuf::from(non_unicode_str);
let err: FromPathBufError = Utf8PathBuf::try_from(non_unicode_path.clone())
    .expect_err("non-Unicode path failed");
assert_eq!(err.as_path(), &non_unicode_path);
assert_eq!(err.into_path_buf(), non_unicode_path);

Implementations

impl FromPathBufError[src]

pub fn as_path(&self) -> &Path[src]

Returns the Path slice that was attempted to be converted to Utf8PathBuf.

pub fn into_path_buf(self) -> PathBuf[src]

Returns the PathBuf that was attempted to be converted to Utf8PathBuf.

pub fn from_path_error(&self) -> FromPathError[src]

Fetch a FromPathError for more about the conversion failure.

At the moment this struct does not contain any additional information, but is provided for completeness.

Trait Implementations

impl Clone for FromPathBufError[src]

impl Debug for FromPathBufError[src]

impl Display for FromPathBufError[src]

impl Eq for FromPathBufError[src]

impl Error for FromPathBufError[src]

impl PartialEq<FromPathBufError> for FromPathBufError[src]

impl StructuralEq for FromPathBufError[src]

impl StructuralPartialEq for FromPathBufError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.