Skip to main content

DecodedField

Struct DecodedField 

Source
pub struct DecodedField {
    pub info: &'static FieldInfo,
    pub value: FieldValue,
    pub bit_offset: Option<u32>,
    pub bit_length: Option<u32>,
    pub repeat_index: Option<u32>,
    pub repeat_set: u8,
    /* private fields */
}
Expand description

One decoded field.

Schema metadata (id, name, order, unit, resolution, precision, part_of_primary_key) is read through accessor methods that delegate to Self::info — the corresponding FieldInfo entry in the static schema. Runtime values that the decoder owns (bit_offset, bit_length, repeat_*, value) stay as direct fields because they can legitimately differ from the schema’s declared values (repeating-set iterations shift the offset; VARIABLE fields can be byte-aligned wider than the schema declares).

VARIABLE and DYNAMIC_FIELD_VALUE fields override unit / resolution / precision with metadata drawn from a target FieldInfo or LookupFieldTypeValue; those overrides live in a boxed [FieldOverrides] sidecar — None in the common path, so the 98 % of fields that don’t override only carry an 8-byte null pointer in the slot.

Fields§

§info: &'static FieldInfo

Pointer back into the static FieldInfo this field was decoded against.

§value: FieldValue§bit_offset: Option<u32>

Bit offset of this field within the parent payload. May differ from info.bit_offset for fields inside repeating sets (each iteration shifts) and for variable-length fields. None for synthetic fields.

§bit_length: Option<u32>

Effective bit length on the wire. May differ from info.bit_length for STRING_LAU / VARIABLE / DYNAMIC_FIELD_VALUE fields (resolved at decode time).

§repeat_index: Option<u32>

Zero-based iteration index for fields inside a repeating set; None for non-repeating fields.

§repeat_set: u8

Which RepeatingFieldSet this field belongs to: 1 → emitted under JSON "list", 2 → under "list2". 0 for non-repeating.

Implementations§

Source§

impl DecodedField

Source

pub fn order(&self) -> u8

canboat.json field Order (1-based schema position).

Source

pub fn id(&self) -> &'static str

canboat.json field Id (camelCase identifier).

Source

pub fn name(&self) -> &'static str

canboat.json field Name (human label).

Source

pub fn unit(&self) -> Option<&'static str>

Display unit. Overridden by VARIABLE / DYNAMIC_FIELD_VALUE resolution; otherwise from FieldInfo::unit.

Source

pub fn as_f64_in(&self, target: &str) -> Option<f64>

This field’s numeric value expressed in target unit, converting from the field’s own unit when they differ (see [crate::engine::units::convert_unit]). A unitless field is returned as-is; a numeric field whose unit has no known bridge to target yields None.

This lets a consumer that needs a fixed unit stay correct no matter which schema (crate::engine::Units) produced the field — e.g. NMEA 0183 always asks angles for "deg" and temperatures for "C", and gets them whether the stream was SI or Metric.

Source

pub fn resolution(&self) -> Option<f64>

Display resolution.

Source

pub fn precision(&self) -> u8

Decimal precision override (0 = derive from resolution).

Source

pub fn part_of_primary_key(&self) -> bool

true if this field participates in the PGN’s primary key.

Trait Implementations§

Source§

impl Clone for DecodedField

Source§

fn clone(&self) -> Self

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 DecodedField

Source§

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

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.