[−][src]Struct utf16string::Utf16Error
Error for invalid UTF-16 encoded bytes.
Implementations
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 byUtf16Error::valid_up_to
. Decoding should resume after that sequence (after inserting aU+FFFD REPLACEMENT CHARACTER
) in case of lossy decoding. In fact for UTF-16 thelen
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]
fn clone(&self) -> Utf16Error
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Utf16Error
[src]
impl Debug for Utf16Error
[src]
impl Display for Utf16Error
[src]
impl Error for Utf16Error
[src]
Auto Trait Implementations
impl RefUnwindSafe for Utf16Error
impl Send for Utf16Error
impl Sync for Utf16Error
impl Unpin for Utf16Error
impl UnwindSafe for Utf16Error
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>,