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§
source§impl 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
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.
sourcepub fn into_io_error(self) -> Error
pub fn into_io_error(self) -> Error
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§
source§impl Clone for FromPathBufError
impl Clone for FromPathBufError
source§fn clone(&self) -> FromPathBufError
fn clone(&self) -> FromPathBufError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FromPathBufError
impl Debug for FromPathBufError
source§impl Display for FromPathBufError
impl Display for FromPathBufError
source§impl Error for FromPathBufError
impl Error for FromPathBufError
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl PartialEq for FromPathBufError
impl PartialEq for FromPathBufError
source§fn 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 ==
.impl Eq for FromPathBufError
impl StructuralPartialEq for FromPathBufError
Auto Trait Implementations§
impl Freeze for FromPathBufError
impl RefUnwindSafe for FromPathBufError
impl Send for FromPathBufError
impl Sync for FromPathBufError
impl Unpin for FromPathBufError
impl UnwindSafe for FromPathBufError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more