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 FieldInfoPointer 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: u8Which RepeatingFieldSet this field belongs to: 1 → emitted
under JSON "list", 2 → under "list2". 0 for non-repeating.
Implementations§
Source§impl DecodedField
impl DecodedField
Sourcepub fn unit(&self) -> Option<&'static str>
pub fn unit(&self) -> Option<&'static str>
Display unit. Overridden by VARIABLE / DYNAMIC_FIELD_VALUE
resolution; otherwise from FieldInfo::unit.
Sourcepub fn as_f64_in(&self, target: &str) -> Option<f64>
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.
Sourcepub fn resolution(&self) -> Option<f64>
pub fn resolution(&self) -> Option<f64>
Display resolution.
Sourcepub fn part_of_primary_key(&self) -> bool
pub fn part_of_primary_key(&self) -> bool
true if this field participates in the PGN’s primary key.