[][src]Struct abi_stable::std_types::string::FromUtf8Error

pub struct FromUtf8Error { /* fields omitted */ }

Error that happens when attempting to convert an RVec<u8> into an RString.

Example

use abi_stable::std_types::RString;

let err=RString::from_utf8(vec![0,0,0,255]).unwrap_err();

assert_eq!( err.as_bytes() , &[0,0,0,255] )

Methods

impl FromUtf8Error[src]

Important traits for RVec<u8>
pub fn into_bytes(self) -> RVec<u8>[src]

Unwraps this error into the bytes that were attempted to convert into an RString.

Example

use abi_stable::std_types::{RString,RVec};

let bytes:RVec<u8>= vec![72, 111, 95, 95, 95, 95, 95, 99, 107, 255].into();

let err=RString::from_utf8(bytes.clone()).unwrap_err();

assert_eq!( err.into_bytes(), bytes );

pub fn as_bytes(&self) -> &[u8][src]

Gets access to bytes that were attempted to convert into an RString.

Example

use abi_stable::std_types::RString;

let bytes= vec![99, 114, 121, 115, 116, 97, 108, 255];

let err=RString::from_utf8(bytes.clone()).unwrap_err();

assert_eq!( err.as_bytes(), &bytes[..] );

pub fn error(&self) -> Utf8Error[src]

Gets a Utf8Error with information about the conversion error.

Example

use abi_stable::std_types::RString;

let err=RString::from_utf8( vec![0, 0, 255] ).unwrap_err();

assert_eq!( err.error().valid_up_to(), 2 );

Trait Implementations

impl Display for FromUtf8Error[src]

impl Debug for FromUtf8Error[src]

impl Error for FromUtf8Error[src]

Auto Trait Implementations

Blanket Implementations

impl<This> TransmuteElement for This where
    This: ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The error type returned when the conversion fails.