Struct PacketFieldSpec

Source
pub struct PacketFieldSpec {
    pub field_id: String,
    pub packet_field_id: String,
    pub name: String,
    pub unit_id: UnitId,
    pub unit_family: UnitFamily,
    pub unit_code: String,
    pub unit_text: String,
    pub precision: i32,
    pub typ: Type,
    pub parts: Vec<PacketTemplateFieldPart>,
    pub language: Language,
}
Expand description

Contains information about a VBus packet field.

§Examples

use resol_vbus::{SpecificationFile, Specification, Language};
use resol_vbus::specification_file::{UnitFamily, Type};

let spec = Specification::from_file(SpecificationFile::new_default(), Language::De);

let packet_spec = spec.get_packet_spec(0x00, 0x0010, 0x7E11, 0x0100);
let packet_field_spec = &packet_spec.fields [0];

assert_eq!("000_2_0", packet_field_spec.field_id);
assert_eq!("00_0010_7E11_10_0100_000_2_0", packet_field_spec.packet_field_id);
assert_eq!("Temperatur Sensor 1", packet_field_spec.name);
assert_eq!(62, packet_field_spec.unit_id.0);
assert_eq!(UnitFamily::Temperature, packet_field_spec.unit_family);
assert_eq!("DegreesCelsius", packet_field_spec.unit_code);
assert_eq!(" °C", packet_field_spec.unit_text);
assert_eq!(1, packet_field_spec.precision);
assert_eq!(Type::Number, packet_field_spec.typ);

Fields§

§field_id: String

A field identifier.

§packet_field_id: String

A packet-field identifier.

§name: String

The name of the field.

§unit_id: UnitId

The UnitId of the field.

§unit_family: UnitFamily

The UnitFamily of the field.

§unit_code: String

The unit code of the field.

§unit_text: String

The unit text of the field.

§precision: i32

The precision of the field.

§typ: Type

The Type of the field.

§parts: Vec<PacketTemplateFieldPart>

The parts the field consists of.

§language: Language

The language used for the specification.

Implementations§

Source§

impl PacketFieldSpec

Source

pub fn raw_value_i64(&self, buf: &[u8]) -> Option<i64>

Construct an i64 raw value from a slice of bytes.

Source

pub fn raw_value_f64(&self, buf: &[u8]) -> Option<f64>

Construct a f64 raw value from a slice of bytes.

Source

pub fn fmt_raw_value( &self, raw_value: Option<i64>, append_unit: bool, ) -> PacketFieldFormatter<'_>

Format a raw value into its textual representation.

Trait Implementations§

Source§

impl Debug for PacketFieldSpec

Source§

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

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

impl PartialEq for PacketFieldSpec

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 StructuralPartialEq for PacketFieldSpec

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, 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.