#[non_exhaustive]pub enum Error {
Show 14 variants
BufferTooShort(BufferTooShort),
CrcMismatch(CrcMismatch),
#[non_exhaustive] UnexpectedTableId {
table_id: u8,
what: &'static str,
expected: &'static [u8],
},
#[non_exhaustive] InvalidDescriptor {
tag: u8,
reason: &'static str,
},
#[non_exhaustive] ValueOutOfRange {
field: &'static str,
reason: &'static str,
},
#[non_exhaustive] CharsetNotEnabled {
charset: LegacyCharset,
},
#[non_exhaustive] SectionLengthOverflow {
declared: usize,
available: usize,
},
#[non_exhaustive] TooLarge {
limit_name: &'static str,
limit_bytes: u64,
},
ReservedBits(ReservedBits),
InvalidValue(InvalidValue),
InvalidField(InvalidField),
OutputBufferTooSmall(OutputBufferTooSmall),
InvalidSync(InvalidSync),
FieldOverflow(FieldOverflow),
}Expand description
Error variants that parsers + builders can return.
Spec references inside #[error(...)] strings quote clauses from
ETSI EN 300 468 v1.19.1 where applicable.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BufferTooShort(BufferTooShort)
Input buffer was shorter than the smallest valid encoding for the type.
CrcMismatch(CrcMismatch)
CRC-32 validation failed for a table section.
#[non_exhaustive]UnexpectedTableId
table_id byte doesn’t match any expected value for the parser invoked.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]InvalidDescriptor
Descriptor payload failed semantic validation.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]ValueOutOfRange
A decoded value passed to a set_* accessor could not be encoded to the
field’s fixed wire representation (e.g. a duration ≥ 100 hours, or a date
outside the 16-bit MJD range).
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]CharsetNotEnabled
Text in a Table A.3 character set whose codec needs the
legacy-charsets feature, decoded with that feature off.
Fields
This variant is marked as non-exhaustive
charset: LegacyCharsetThe character set the selector names.
#[non_exhaustive]SectionLengthOverflow
A section_length declared more bytes than the containing buffer could hold.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]TooLarge
A whole document exceeded the named byte limit it was read under.
Fields
This variant is marked as non-exhaustive
ReservedBits(ReservedBits)
A reserved or fixed-value bit group was not in the state a spec clause requires. Most parsers are permissive about reserved bits; this is only emitted when a clause specifically requires a value.
InvalidValue(InvalidValue)
A field held a value its spec clause forbids.
InvalidField(InvalidField)
A field is structurally invalid with no single offending number.
OutputBufferTooSmall(OutputBufferTooSmall)
Write buffer passed to serialize_into was smaller than serialized_len().
InvalidSync(InvalidSync)
A fixed marker did not match (TS sync byte, expected 0x47).
FieldOverflow(FieldOverflow)
A serializer’s length or count value did not fit its wire field.
Returned instead of silently narrowing (as u8/as u16/masking),
which would emit a misframed section (see #1129).
Implementations§
Source§impl Error
impl Error
Sourcepub fn too_large(limit_name: &'static str, limit_bytes: u64) -> Self
pub fn too_large(limit_name: &'static str, limit_bytes: u64) -> Self
Builds Self::TooLarge.
Sourcepub fn invalid_descriptor(tag: u8, reason: &'static str) -> Self
pub fn invalid_descriptor(tag: u8, reason: &'static str) -> Self
Builds Self::InvalidDescriptor.
Sourcepub fn section_length_overflow(declared: usize, available: usize) -> Self
pub fn section_length_overflow(declared: usize, available: usize) -> Self
Builds Self::SectionLengthOverflow.
Sourcepub fn value_out_of_range(field: &'static str, reason: &'static str) -> Self
pub fn value_out_of_range(field: &'static str, reason: &'static str) -> Self
Builds Self::ValueOutOfRange.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
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()