Skip to main content

FitError

Enum FitError 

Source
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

§expected: usize

Minimum number of bytes required.

§actual: usize

Actual number of bytes available.

§

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

§stored: u16

CRC value stored in the header.

§calculated: u16

CRC computed over the header bytes.

§

FileCrcMismatch

The two trailing CRC bytes do not match the CRC computed over the header + data region preceding them.

Fields

§stored: u16

CRC value stored in the file trailer.

§calculated: u16

CRC computed over header + data region.

§

UnexpectedEof

Attempted to read past the end of the byte stream.

Fields

§offset: usize

Byte offset where the read failed.

§

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

§field_def_num: u8

Field definition number that failed validation.

§size: u8

Wire size in bytes.

§element_size: usize

Base type element size in bytes.

§

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: FieldTooLargeKind

What kind of object exceeded the limit.

§size: usize

The actual (oversized) value.

Trait Implementations§

Source§

impl Debug for FitError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for FitError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for FitError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for FitError

Source§

fn eq(&self, other: &FitError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for FitError

Source§

impl StructuralPartialEq for FitError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.