Struct camino::FromPathBufError[][src]

pub struct FromPathBufError { /* fields omitted */ }
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.

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

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

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. 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 method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.