[−][src]Struct tinyvec_string::arraystring::FromUtf8Error
A possible error value when converting an ArrayString from a UTF-8 byte
vector.
This type is the error type for the from_utf8 method on ArrayString.
The into_bytes method will give back the byte vector that was used in
the conversion attempt.
The Utf8Error type provided by std::str represents an error that may
occur when converting a slice of u8s to a &str. In this sense, it's
an analogue to FromUtf8Error, and you can get one from a FromUtf8Error
through the utf8_error method.
Examples
use tinyvec::{array_vec, ArrayVec}; // some invalid bytes, in a vector let bytes: ArrayVec<[u8; 2]> = array_vec![0, 159]; let value = ArrayString::from_utf8(bytes); assert_eq!(Err(array_vec![0, 159]), value.map_err(|e| e.into_bytes()));
Implementations
impl<A: ByteArray> FromUtf8Error<A>[src]
pub fn as_bytes(&self) -> &[u8]ⓘ[src]
Returns a slice of u8s bytes that were attempted to convert to an
ArrayString.
Examples
use tinyvec::{array_vec, ArrayVec}; // some invalid bytes, in a vector let bytes: ArrayVec<[u8; 2]> = array_vec![0, 159]; let value = ArrayString::from_utf8(bytes); assert_eq!(&[0, 159], value.unwrap_err().as_bytes());
pub fn into_bytes(self) -> ArrayVec<A>[src]
Returns the bytes that were attempted to convert to a String.
Examples
use tinyvec::{array_vec, ArrayVec}; // some invalid bytes, in a vector let bytes: ArrayVec<[u8; 2]> = array_vec![0, 159]; let value = ArrayString::from_utf8(bytes); assert_eq!(array_vec![0, 159], value.unwrap_err().into_bytes());
pub fn utf8_error(&self) -> Utf8Error[src]
Fetch a Utf8Error to get more details about the conversion failure.
The Utf8Error type provided by std::str represents an error that may
occur when converting a slice of u8s to a &str. In this sense, it's
an analogue to FromUtf8Error. See its documentation for more details
on using it.
Examples
use tinyvec::{array_vec, ArrayVec}; // some invalid bytes, in a vector let bytes: ArrayVec<[u8; 2]> = array_vec![0, 159]; let error = ArrayString::from_utf8(bytes).unwrap_err().utf8_error(); // the first byte is invalid here assert_eq!(1, error.valid_up_to());
Trait Implementations
impl<A: Clone + ByteArray> Clone for FromUtf8Error<A>[src]
fn clone(&self) -> FromUtf8Error<A>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<A: Copy + ByteArray> Copy for FromUtf8Error<A>[src]
impl<A: ByteArray> Debug for FromUtf8Error<A>[src]
impl<A: ByteArray> Display for FromUtf8Error<A>[src]
impl<A: Eq + ByteArray> Eq for FromUtf8Error<A>[src]
impl<A: ByteArray> Error for FromUtf8Error<A>[src]
fn source(&self) -> Option<&(dyn Error + 'static)>1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>[src]
fn description(&self) -> &str1.0.0[src]
fn cause(&self) -> Option<&dyn Error>1.0.0[src]
impl<A: PartialEq + ByteArray> PartialEq<FromUtf8Error<A>> for FromUtf8Error<A>[src]
fn eq(&self, other: &FromUtf8Error<A>) -> bool[src]
fn ne(&self, other: &FromUtf8Error<A>) -> bool[src]
impl<A: ByteArray> StructuralEq for FromUtf8Error<A>[src]
impl<A: ByteArray> StructuralPartialEq for FromUtf8Error<A>[src]
Auto Trait Implementations
impl<A> RefUnwindSafe for FromUtf8Error<A> where
A: RefUnwindSafe,
A: RefUnwindSafe,
impl<A> Send for FromUtf8Error<A> where
A: Send,
A: Send,
impl<A> Sync for FromUtf8Error<A> where
A: Sync,
A: Sync,
impl<A> Unpin for FromUtf8Error<A> where
A: Unpin,
A: Unpin,
impl<A> UnwindSafe for FromUtf8Error<A> where
A: UnwindSafe,
A: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,