pub struct DecodeError {
pub offset: usize,
pub length: usize,
pub kind: DecodeErrorKind,
}Expand description
An error reported by Decoder::decode_to_string.
All positional information (offset, length) is expressed in bytes and is relative to the
input slice passed to the specific decode_to_string call
that returned this error — not to the logical start of the overall byte stream. A caller
tracking a running total offset across chunks should add the sum of the lengths of all
previously-consumed chunks to offset to obtain a stream-relative position.
When the malformed data spans a chunk boundary (part of it was buffered internally from a
previous call), offset is clamped to 0: the problem became visible only once the new
bytes arrived, so 0 is the most useful position a caller can act on (for example, to slice
input[..0] off before the error and report the rest as unconsumed).
Fields§
§offset: usizeByte offset within the input slice of the call that failed.
length: usizeThe number of bytes that make up the malformed/incomplete unit, where known. This is a
hint for error-recovery strategies (e.g. “skip length bytes and retry”); it may be 0
when no specific byte range is at fault (e.g. an unpaired surrogate detected only once a
following code unit failed to complete the pair).
kind: DecodeErrorKindWhat kind of problem was found.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§fn clone(&self) -> DecodeError
fn clone(&self) -> DecodeError
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 DecodeError
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
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()