pub struct Utf16Error { /* private fields */ }Expand description
Error for invalid UTF-16 encoded bytes.
Implementations§
Source§impl Utf16Error
impl Utf16Error
Sourcepub fn valid_up_to(&self) -> usize
pub fn valid_up_to(&self) -> usize
Returns the index in given bytes up to which valid UTF-16 was verified.
Sourcepub fn error_len(&self) -> Option<usize>
pub fn error_len(&self) -> Option<usize>
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 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 thelenreported 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§
Source§impl Clone for Utf16Error
impl Clone for Utf16Error
Source§fn clone(&self) -> Utf16Error
fn clone(&self) -> Utf16Error
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Utf16Error
impl Debug for Utf16Error
Source§impl Display for Utf16Error
impl Display for Utf16Error
Source§impl Error for Utf16Error
impl Error for Utf16Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
impl Copy for Utf16Error
Auto Trait Implementations§
impl Freeze for Utf16Error
impl RefUnwindSafe for Utf16Error
impl Send for Utf16Error
impl Sync for Utf16Error
impl Unpin for Utf16Error
impl UnwindSafe for Utf16Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes