pub enum CharsetDecodeErrorKind {
MalformedSequence {
value: Option<u32>,
},
InvalidInputIndex {
input_len: usize,
},
InvalidOutputIndex {
output_len: usize,
},
IncompleteSequence {
required: usize,
available: usize,
},
InvalidCodePoint {
value: u32,
},
}Expand description
Classifies failures detected while decoding encoded units into Unicode text.
Variants§
MalformedSequence
The input units do not form a well-formed encoded sequence.
InvalidInputIndex
The requested input unit index is outside the input buffer.
InvalidOutputIndex
The requested output character index is outside the output buffer.
IncompleteSequence
The closed input ended before a complete character was available.
Fields
InvalidCodePoint
The decoded numeric value is not a valid Unicode scalar value.
Implementations§
Source§impl CharsetDecodeErrorKind
impl CharsetDecodeErrorKind
Sourcepub const fn required(self) -> Option<usize>
pub const fn required(self) -> Option<usize>
Returns the number of required input units for this kind, if available.
§Returns
Some(required)forSelf::IncompleteSequence;Nonefor all other variants.
Sourcepub const fn available(self) -> Option<usize>
pub const fn available(self) -> Option<usize>
Returns the number of currently available input units for this kind, if available.
§Returns
Some(available)forSelf::IncompleteSequence;Nonefor all other variants.
Sourcepub const fn value(self) -> Option<u32>
pub const fn value(self) -> Option<u32>
Returns the raw malformed value associated with this decoding error, if any.
§Returns
Some(value)forSelf::MalformedSequencewhen a specific malformed unit value is available.Some(value)forSelf::InvalidCodePoint.Nonefor other variants.
Sourcepub const fn input_len(self) -> Option<usize>
pub const fn input_len(self) -> Option<usize>
Returns the input length when this error comes from an invalid input index.
§Returns
Some(input_len)forSelf::InvalidInputIndex;Nonefor other variants.
Sourcepub const fn output_len(self) -> Option<usize>
pub const fn output_len(self) -> Option<usize>
Returns the output length when this error comes from an invalid output index.
§Returns
Some(output_len)forSelf::InvalidOutputIndex;Nonefor other variants.
Sourcepub const fn is_incomplete(self) -> bool
pub const fn is_incomplete(self) -> bool
Returns whether this kind represents incomplete input.
§Returns
Returns true for Self::IncompleteSequence.
Sourcepub const fn incomplete(self) -> Option<(usize, usize)>
pub const fn incomplete(self) -> Option<(usize, usize)>
Returns incomplete-input details for this kind.
§Returns
Returns Some((required, available)) for Self::IncompleteSequence,
or None for all other variants.
Sourcepub const fn is_malformed_input(self) -> bool
pub const fn is_malformed_input(self) -> bool
Returns whether this kind represents malformed encoded input.
§Returns
Returns true for malformed sequences and invalid decoded scalar
values. Incomplete input is caller-owned tail data and is not
treated as malformed input by buffered charset decoders.
Trait Implementations§
Source§impl Clone for CharsetDecodeErrorKind
impl Clone for CharsetDecodeErrorKind
Source§fn clone(&self) -> CharsetDecodeErrorKind
fn clone(&self) -> CharsetDecodeErrorKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CharsetDecodeErrorKind
Source§impl Debug for CharsetDecodeErrorKind
impl Debug for CharsetDecodeErrorKind
Source§impl Display for CharsetDecodeErrorKind
impl Display for CharsetDecodeErrorKind
impl Eq for CharsetDecodeErrorKind
Source§impl Error for CharsetDecodeErrorKind
impl Error for CharsetDecodeErrorKind
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
use the Display impl or to_string()
Source§impl PartialEq for CharsetDecodeErrorKind
impl PartialEq for CharsetDecodeErrorKind
Source§fn eq(&self, other: &CharsetDecodeErrorKind) -> bool
fn eq(&self, other: &CharsetDecodeErrorKind) -> bool
self and other values to be equal, and is used by ==.