[−][src]Enum rustf8::Utf8IteratorError
The Utf8Iterator
will identify UTF-8 decoding errors returning the enum Utf8IteratorError
.
The error will also contain a Box<u8>
with the malformed sequence.
Example
fn next_token (chiter: &mut Utf8Iterator<Bytes<Cursor<&str>>>, state: &mut (State, Token)) -> Option<Token> { loop { let r = chiter.next(); match r { Some(item) => match item { Ok(ch) => { *state = state_machine(chiter, ch, &state); if let State::FinishedToken = state.0 { return Some(state.1.clone()); } } Err(e) => match e { InvalidSequenceError(bytes) => { panic!("Detected an invalid UTF-8 sequence! {:?}", bytes) } LongSequenceError(bytes) => { panic!("UTF-8 sequence with more tha 4 bytes! {:?}", bytes) } InvalidCharError(bytes) => panic!( "UTF-8 sequence resulted in an invalid character! {:?}", bytes ), IoError(ioe, bytes) => panic!( "I/O error {:?} while decoding de sequence {:?} !", ioe, bytes ), }, }, None => { if let State::Finalized = state.0 { return None; } else { state.0 = State::Finalized; return Some(state.1.clone()); } } } } };
Variants
Returns the IO error coming from the underling iterator wrapped by Utf8Iterator
.
The error std::io::ErrorKind::Interrupted
is consumed by the iterator and is not returned.
The decoder found a malformed sequence.
The sequence is well formed, but it is too long (more than 4 bytes).
Found a well formed UTF-8 sequence, nevertheless the value does not represent a valid character.
Trait Implementations
impl Debug for Utf8IteratorError
[src]
impl Display for Utf8IteratorError
[src]
impl Error for Utf8IteratorError
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Utf8IteratorError
impl Send for Utf8IteratorError
impl Sync for Utf8IteratorError
impl Unpin for Utf8IteratorError
impl !UnwindSafe for Utf8IteratorError
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> 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>,