pub struct CharsetDecodeError { /* private fields */ }Expand description
Error reported by a charset decoder.
The error always carries the charset, error kind, and input unit index at
which the failure was detected. Errors that decode a raw numeric value, such
as invalid UTF-32 units, carry that value through Self::kind and
Self::value. Invalid-input errors may also carry a consumed-unit count
so buffered decoders can make progress without an extra status wrapper.
Implementations§
Source§impl CharsetDecodeError
impl CharsetDecodeError
Sourcepub const fn new(
charset: Charset,
kind: CharsetDecodeErrorKind,
index: usize,
) -> Self
pub const fn new( charset: Charset, kind: CharsetDecodeErrorKind, index: usize, ) -> Self
Sourcepub const fn with_consumed(self, consumed: usize) -> Self
pub const fn with_consumed(self, consumed: usize) -> Self
Sourcepub const fn kind(self) -> CharsetDecodeErrorKind
pub const fn kind(self) -> CharsetDecodeErrorKind
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
Returns the input unit index associated with this error.
§Returns
Returns the index at which the error was detected.
Sourcepub const fn required(self) -> Option<usize>
pub const fn required(self) -> Option<usize>
Returns required input units for this decoding error, if reported.
§Returns
Returns Some(required) for
CharsetDecodeErrorKind::IncompleteSequence, otherwise None.
Sourcepub const fn available(self) -> Option<usize>
pub const fn available(self) -> Option<usize>
Returns available input units for this decoding error, if reported.
§Returns
Returns Some(available) for
CharsetDecodeErrorKind::IncompleteSequence, otherwise None.
Sourcepub const fn input_len(self) -> Option<usize>
pub const fn input_len(self) -> Option<usize>
Returns input length for this decoding error, if reported.
§Returns
Returns Some(input_len) for
CharsetDecodeErrorKind::InvalidInputIndex, otherwise None.
Sourcepub const fn output_len(self) -> Option<usize>
pub const fn output_len(self) -> Option<usize>
Returns output length for this decoding error, if reported.
§Returns
Returns Some(output_len) for
CharsetDecodeErrorKind::InvalidOutputIndex, otherwise None.
Sourcepub const fn value(self) -> Option<u32>
pub const fn value(self) -> Option<u32>
Returns the raw value associated with this error.
§Returns
Returns Some(value) when the error kind carries a raw unit or code
point value, or None for kinds without an associated value.
Sourcepub const fn consumed(self) -> Option<usize>
pub const fn consumed(self) -> Option<usize>
Returns units that may be consumed after this invalid-input error.
§Returns
Returns Some(consumed) for malformed and invalid-code-point input, or
None for incomplete input and invalid caller indexes.
Sourcepub const fn offset_by(self, base: usize) -> Self
pub const fn offset_by(self, base: usize) -> Self
Offsets this error by a base unit index.
§Parameters
base: The base index to add to the stored index.
§Returns
Returns a copy of this error with its index shifted by base.
If the shifted index cannot be represented, it is saturated to
usize::MAX.
Trait Implementations§
Source§impl Clone for CharsetDecodeError
impl Clone for CharsetDecodeError
Source§fn clone(&self) -> CharsetDecodeError
fn clone(&self) -> CharsetDecodeError
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 CharsetDecodeError
Source§impl Debug for CharsetDecodeError
impl Debug for CharsetDecodeError
Source§impl Display for CharsetDecodeError
impl Display for CharsetDecodeError
impl Eq for CharsetDecodeError
Source§impl Error for CharsetDecodeError
impl Error for CharsetDecodeError
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 From<CharsetDecodeError> for CharsetConvertError
impl From<CharsetDecodeError> for CharsetConvertError
Source§fn from(source: CharsetDecodeError) -> Self
fn from(source: CharsetDecodeError) -> Self
Source§impl PartialEq for CharsetDecodeError
impl PartialEq for CharsetDecodeError
Source§fn eq(&self, other: &CharsetDecodeError) -> bool
fn eq(&self, other: &CharsetDecodeError) -> bool
self and other values to be equal, and is used by ==.