[−][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 u8
s 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 u8
s 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 u8
s 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]
pub fn clone(&self) -> FromUtf8Error<A>
[src]
pub 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]
std
only.pub fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]
pub fn backtrace(&self) -> Option<&Backtrace>
[src]
pub fn description(&self) -> &str
1.0.0[src]
pub fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl<A: PartialEq + ByteArray> PartialEq<FromUtf8Error<A>> for FromUtf8Error<A>
[src]
pub fn eq(&self, other: &FromUtf8Error<A>) -> bool
[src]
pub 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,
[src]
A: RefUnwindSafe,
impl<A> Send for FromUtf8Error<A> where
A: Send,
[src]
A: Send,
impl<A> Sync for FromUtf8Error<A> where
A: Sync,
[src]
A: Sync,
impl<A> Unpin for FromUtf8Error<A> where
A: Unpin,
[src]
A: Unpin,
impl<A> UnwindSafe for FromUtf8Error<A> where
A: UnwindSafe,
[src]
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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,