pub enum FitError {
TooShort {
expected: usize,
actual: usize,
},
InvalidHeaderSize(u8),
InvalidSignature([u8; 4]),
HeaderCrcMismatch {
stored: u16,
calculated: u16,
},
FileCrcMismatch {
stored: u16,
calculated: u16,
},
UnexpectedEof {
offset: usize,
},
UnknownBaseType(u8, u8),
UndefinedLocalMesgNum(u8),
NonZeroReserved(u8),
MalformedField {
field_def_num: u8,
size: u8,
element_size: usize,
},
TooManyLocalDefinitions(usize),
FieldTooLarge {
kind: FieldTooLargeKind,
size: usize,
},
}Expand description
Anything that can go wrong while reading a FIT file.
Variants§
TooShort
The byte slice is shorter than required for the operation in progress.
Fields
InvalidHeaderSize(u8)
The header size byte (offset 0) is neither 12 nor 14.
InvalidSignature([u8; 4])
The 4-byte signature at offset 8..12 is not the ASCII string ".FIT".
HeaderCrcMismatch
The 14-byte header carries a non-zero CRC that does not match the
CRC computed over its own first 12 bytes. Per protocol, a stored CRC
of 0x0000 is treated as “skip verification” (legacy firmware) and
will not trigger this error.
Fields
FileCrcMismatch
The two trailing CRC bytes do not match the CRC computed over the header + data region preceding them.
Fields
UnexpectedEof
Attempted to read past the end of the byte stream.
UnknownBaseType(u8, u8)
A field-definition byte’s type code (after & 0x1F) does not match
any of the 17 known base types.
UndefinedLocalMesgNum(u8)
A Data message references a local message number that has not been declared by a preceding Definition message.
NonZeroReserved(u8)
The reserved byte at offset 1 of a Definition message was non-zero. We don’t error on this in production parsing (just a warning), but the variant exists for strict-mode tooling.
MalformedField
A field’s wire size is not a multiple of its base type’s element size, so the byte stream cannot be cleanly partitioned into elements.
Fields
TooManyLocalDefinitions(usize)
The encoder was asked to emit more than 16 distinct global message numbers in a single FIT segment. Local definition slots are limited to 4 bits (0..=15) by the protocol; LRU eviction will arrive in M9.
FieldTooLarge
A field’s wire size or count exceeds 255 bytes (u8 limit).
Fields
kind: FieldTooLargeKindWhat kind of object exceeded the limit.
Trait Implementations§
Source§impl Error for FitError
impl Error for FitError
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()