Error for invalid UTF-16 encoded bytes.
pub fn valid_up_to(&self) -> usize[src]
Returns the index in given bytes up to which valid UTF-16 was verified.
Return the length of the error if it is recoverable.
None: the end of the input was reached unexpectedly.
Utf16Error::valid_up_tois 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
lenreported 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
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]
impl RefUnwindSafe for Utf16Error
impl Send for Utf16Error
impl Sync for Utf16Error
impl Unpin for Utf16Error
impl UnwindSafe for Utf16Error
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)[src]
type Error = Infallible
The type returned in the event of a conversion error.