pub struct FromOsStringError { /* private fields */ }
Expand description
A possible error value while converting a OsString
to a Utf8PathBuf
.
Produced by the TryFrom<OsString>
implementation for Utf8PathBuf
.
§Examples
use camino::{Utf8PathBuf, FromOsStringError};
use std::convert::{TryFrom, TryInto};
use std::ffi::OsStr;
use std::str::FromStr;
use std::ffi::OsString;
use std::os::unix::ffi::OsStrExt;
let unicode_string = OsString::from_str("/valid/unicode").unwrap();
let utf8_path_buf: Utf8PathBuf = unicode_string.try_into()
.expect("valid Unicode path succeeded");
// Paths on Unix can be non-UTF-8.
let non_unicode_string = OsStr::from_bytes(b"\xFF\xFF\xFF").to_owned();
let err: FromOsStringError = Utf8PathBuf::try_from(non_unicode_string.clone())
.expect_err("non-Unicode path failed");
assert_eq!(err.as_os_str(), &non_unicode_string);
assert_eq!(err.into_os_string(), non_unicode_string);
Implementations§
Source§impl FromOsStringError
impl FromOsStringError
Sourcepub fn as_os_str(&self) -> &OsStr
pub fn as_os_str(&self) -> &OsStr
Returns the OsStr
slice that was attempted to be converted to Utf8PathBuf
.
Sourcepub fn into_os_string(self) -> OsString
pub fn into_os_string(self) -> OsString
Returns the OsString
that was attempted to be converted to Utf8PathBuf
.
Sourcepub fn from_os_str_error(&self) -> FromOsStrError
pub fn from_os_str_error(&self) -> FromOsStrError
Fetches a FromOsStrError
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 FromOsStringError
will want to convert it into an io::Error
.
This is a convenience method to do that.
Trait Implementations§
Source§impl Clone for FromOsStringError
impl Clone for FromOsStringError
Source§fn clone(&self) -> FromOsStringError
fn clone(&self) -> FromOsStringError
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for FromOsStringError
impl Debug for FromOsStringError
Source§impl Display for FromOsStringError
impl Display for FromOsStringError
Source§impl Error for FromOsStringError
impl Error for FromOsStringError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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 FromOsStringError
impl PartialEq for FromOsStringError
impl Eq for FromOsStringError
impl StructuralPartialEq for FromOsStringError
Auto Trait Implementations§
impl Freeze for FromOsStringError
impl RefUnwindSafe for FromOsStringError
impl Send for FromOsStringError
impl Sync for FromOsStringError
impl Unpin for FromOsStringError
impl UnwindSafe for FromOsStringError
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