Skip to main content

BaseType

Enum BaseType 

Source
#[repr(u8)]
pub enum BaseType {
Show 17 variants Enum = 0, SInt8 = 1, UInt8 = 2, SInt16 = 3, UInt16 = 4, SInt32 = 5, UInt32 = 6, String = 7, Float32 = 8, Float64 = 9, UInt8z = 10, UInt16z = 11, UInt32z = 12, Byte = 13, SInt64 = 14, UInt64 = 15, UInt64z = 16,
}
Expand description

The 17 FIT base types, indexed by their type-code byte.

Variants§

§

Enum = 0

0x00 — 1-byte enumeration. Invalid: 0xFF.

§

SInt8 = 1

0x01 — signed 8-bit. Invalid: 0x7F.

§

UInt8 = 2

0x02 — unsigned 8-bit. Invalid: 0xFF.

§

SInt16 = 3

0x03 — signed 16-bit. Invalid: 0x7FFF.

§

UInt16 = 4

0x04 — unsigned 16-bit. Invalid: 0xFFFF.

§

SInt32 = 5

0x05 — signed 32-bit. Invalid: 0x7FFFFFFF.

§

UInt32 = 6

0x06 — unsigned 32-bit. Invalid: 0xFFFFFFFF.

§

String = 7

0x07 — null-terminated UTF-8. Invalid: empty / first byte 0x00.

§

Float32 = 8

0x08 — IEEE 754 single. Invalid: bit-pattern 0xFFFFFFFF.

§

Float64 = 9

0x09 — IEEE 754 double. Invalid: bit-pattern 0xFFFFFFFFFFFFFFFF.

§

UInt8z = 10

0x0A — unsigned 8-bit (Z series). Invalid: 0x00.

§

UInt16z = 11

0x0B — unsigned 16-bit (Z series). Invalid: 0x0000.

§

UInt32z = 12

0x0C — unsigned 32-bit (Z series). Invalid: 0x00000000.

§

Byte = 13

0x0D — opaque byte array. Invalid: all elements 0xFF (special rule: a single 0xFF element is not invalid in a multi-byte array).

§

SInt64 = 14

0x0E — signed 64-bit. Invalid: 0x7FFFFFFFFFFFFFFF.

§

UInt64 = 15

0x0F — unsigned 64-bit. Invalid: 0xFFFFFFFFFFFFFFFF.

§

UInt64z = 16

0x10 — unsigned 64-bit (Z series). Invalid: 0x0000000000000000.

The 17th and largest valid type code; missing from many older references but defined in current FIT SDKs.

Implementations§

Source§

impl BaseType

Source

pub const TYPE_CODE_MASK: u8 = 0x1F

Mask to extract the type code from a field-type byte (drops endian flag).

Source

pub const ENDIAN_FLAG: u8 = 0x80

Endian flag bit (bit 7 of a field-type byte).

Source

pub fn from_byte(byte: u8) -> Result<Self, FitError>

Decode a raw field-type byte.

Bit 7 (the endian flag) is masked off; only the low 5 bits are consulted. Returns FitError::UnknownBaseType if the type code is outside the valid range 0x00..=0x10.

Source

pub fn endian_flag_set(byte: u8) -> bool

True iff bit 7 of the raw field-type byte indicates big-endian.

Source

pub fn element_size(&self) -> usize

Size in bytes of a single element of this type. For the variable- length types (BaseType::String and BaseType::Byte) this is the stride per element (1 byte); the actual payload size comes from the Field Size byte in the Definition message.

Source

pub fn is_z_type(&self) -> bool

True for the Z series — types whose invalid sentinel is all zero rather than all ones. Important for invalid-value detection in M4.

Source

pub fn is_byte(&self) -> bool

True for BaseType::Byte. Required because the Byte type has a special invalid-value rule (only invalid when every element is 0xFF).

Source

pub fn is_string(&self) -> bool

True for BaseType::String.

Source

pub fn type_code(&self) -> u8

Raw type code byte (0x00..=0x10). Since BaseType is #[repr(u8)], this is the discriminant value — suitable for writing in a Definition message’s field definition.

Trait Implementations§

Source§

impl Clone for BaseType

Source§

fn clone(&self) -> BaseType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BaseType

Source§

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

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

impl Hash for BaseType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BaseType

Source§

fn eq(&self, other: &BaseType) -> 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 Copy for BaseType

Source§

impl Eq for BaseType

Source§

impl StructuralPartialEq for BaseType

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.