[−][src]Struct strchunk::ExtractUtf8Error
An error returned by StrChunk::extract_utf8.
ExtractUtf8Error indicates an invalid UTF-8 sequence encountered
in the input and provides information necessary for lossy recovery
of an incremental UTF-8 decoding stream.
Example
const TEST_DATA: &[u8] = b"Hello \xF0\x90\x80World"; let mut input = BytesMut::from(TEST_DATA); let err = StrChunk::extract_utf8(&mut input).unwrap_err(); input.advance(err.error_len()); let chunk1 = err.into_extracted(); assert_eq!(chunk1, "Hello "); // Can inject a replacement character into the output, e.g. U+FFFD let chunk2 = StrChunk::extract_utf8(&mut input).unwrap(); assert_eq!(chunk2, "World");
Implementations
impl ExtractUtf8Error[src]
pub fn error_len(&self) -> usize[src]
Length of the invalid byte sequence.
A lossy decoding procedure should advance the reading position
by the returned amount using the advance method of the input buffer
to resume decoding.
pub fn into_extracted(self) -> StrChunk[src]
Consumes self to obtain the string content extracted up to
the encountered invalid sequence.
Trait Implementations
impl Clone for ExtractUtf8Error[src]
fn clone(&self) -> ExtractUtf8Error[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for ExtractUtf8Error[src]
impl Display for ExtractUtf8Error[src]
impl Error for ExtractUtf8Error[src]
Auto Trait Implementations
impl RefUnwindSafe for ExtractUtf8Error[src]
impl Send for ExtractUtf8Error[src]
impl Sync for ExtractUtf8Error[src]
impl Unpin for ExtractUtf8Error[src]
impl UnwindSafe for ExtractUtf8Error[src]
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,
pub 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.
pub fn to_owned(&self) -> T[src]
pub 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.
pub 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>,