[][src]Struct utf16string::Utf16Error

pub struct Utf16Error { /* fields omitted */ }

Error for invalid UTF-16 encoded bytes.


impl Utf16Error[src]

pub fn valid_up_to(&self) -> usize[src]

Returns the index in given bytes up to which valid UTF-16 was verified.

pub fn error_len(&self) -> Option<usize>[src]

Return the length of the error if it is recoverable.

  • None: the end of the input was reached unexpectedly. Utf16Error::valid_up_to is 1 to 3 bytes from the end of the input. If a byte stream such as a file or a network socket is being decoded incrementally, this could still be a valid char whose byte sequence is spanning multiple chunks.

  • Some(len): an unexpected byte was encountered. The length provided is that of the invalid byte sequence that starts at the index given by Utf16Error::valid_up_to. Decoding should resume after that sequence (after inserting a U+FFFD REPLACEMENT CHARACTER) in case of lossy decoding. In fact for UTF-16 the len reported here will always be exactly 2 since this never looks ahead to see if the bytes following the error sequence are valid as well as otherwise you would not know how many replacement characters to insert when writing a lossy decoder.

The semantics of this API are compatible with the semantics of Utf8Error.

Trait Implementations

impl Clone for Utf16Error[src]

impl Copy for Utf16Error[src]

impl Debug for Utf16Error[src]

impl Display for Utf16Error[src]

impl Error for Utf16Error[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.