pub struct FromPathBufError { /* private fields */ }
Expand description

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§

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

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

Fetches a FromPathError for more about the conversion failure.

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

Converts self into a std::io::Error with kind InvalidData.

Many users of FromPathBufError will want to convert it into an io::Error. This is a convenience method to do that.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The lower-level source of this error, if any. Read more
👎Deprecated since 1.42.0: use the Display impl or to_string()
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.