Struct camino::FromPathBufError
source · [−]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
sourceimpl FromPathBufError
impl FromPathBufError
sourcepub fn as_path(&self) -> &Path
pub fn as_path(&self) -> &Path
Returns the Path
slice that was attempted to be converted to Utf8PathBuf
.
sourcepub fn into_path_buf(self) -> PathBuf
pub fn into_path_buf(self) -> PathBuf
Returns the PathBuf
that was attempted to be converted to Utf8PathBuf
.
sourcepub fn from_path_error(&self) -> FromPathError
pub fn from_path_error(&self) -> FromPathError
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
sourceimpl Clone for FromPathBufError
impl Clone for FromPathBufError
sourcefn clone(&self) -> FromPathBufError
fn clone(&self) -> FromPathBufError
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FromPathBufError
impl Debug for FromPathBufError
sourceimpl Display for FromPathBufError
impl Display for FromPathBufError
sourceimpl Error for FromPathBufError
impl Error for FromPathBufError
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl PartialEq<FromPathBufError> for FromPathBufError
impl PartialEq<FromPathBufError> for FromPathBufError
sourcefn eq(&self, other: &FromPathBufError) -> bool
fn eq(&self, other: &FromPathBufError) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FromPathBufError) -> bool
fn ne(&self, other: &FromPathBufError) -> bool
This method tests for !=
.
impl Eq for FromPathBufError
impl StructuralEq for FromPathBufError
impl StructuralPartialEq for FromPathBufError
Auto Trait Implementations
impl RefUnwindSafe for FromPathBufError
impl Send for FromPathBufError
impl Sync for FromPathBufError
impl Unpin for FromPathBufError
impl UnwindSafe for FromPathBufError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more