Struct FromUtf8Error
struct FromUtf8Error { ... }
An error that may occur when converting a Vec<u8> to a String.
This error includes the original Vec<u8> that failed to convert to a
String. This permits callers to recover the allocation used even if it
it not valid UTF-8.
Examples
Basic usage:
use ;
let bytes = Vecfrom_slice;
let err = bytes.into_string.unwrap_err;
assert_eq!;
assert_eq!;
// At no point in this example is an allocation performed.
let bytes = Vecfrom;
assert_eq!;
Implementations
impl FromUtf8Error
fn as_bytes(self: &Self) -> &[u8]Return the original bytes as a slice that failed to convert to a
String.Examples
Basic usage:
use ; let bytes = Vecfrom_slice; let err = bytes.into_string.unwrap_err; // At no point in this example is an allocation performed. assert_eq!;fn into_vec(self: Self) -> Vec<u8>Consume this error and return the original byte string that failed to convert to a
String.Examples
Basic usage:
use ; let bytes = Vecfrom_slice; let err = bytes.into_string.unwrap_err; let original = err.into_vec; // At no point in this example is an allocation performed. assert_eq!;fn utf8_error(self: &Self) -> &Utf8ErrorReturn the underlying UTF-8 error that occurred. This error provides information on the nature and location of the invalid UTF-8 detected.
Examples
Basic usage:
use ; let bytes = Vecfrom_slice; let err = bytes.into_string.unwrap_err; assert_eq!; assert_eq!;
impl Debug for FromUtf8Error
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Display for FromUtf8Error
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for FromUtf8Error
impl Error for FromUtf8Error
fn description(self: &Self) -> &str
impl Freeze for FromUtf8Error
impl PartialEq for FromUtf8Error
fn eq(self: &Self, other: &FromUtf8Error) -> bool
impl RefUnwindSafe for FromUtf8Error
impl Send for FromUtf8Error
impl StructuralPartialEq for FromUtf8Error
impl Sync for FromUtf8Error
impl Unpin for FromUtf8Error
impl UnsafeUnpin for FromUtf8Error
impl UnwindSafe for FromUtf8Error
impl<T> Any for FromUtf8Error
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for FromUtf8Error
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for FromUtf8Error
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for FromUtf8Error
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToString for FromUtf8Error
fn to_string(self: &Self) -> String
impl<T, U> Into for FromUtf8Error
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for FromUtf8Error
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for FromUtf8Error
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>