Struct PacketSpec

Source
pub struct PacketSpec {
    pub packet_id: String,
    pub channel: u8,
    pub destination_address: u16,
    pub source_address: u16,
    pub command: u16,
    pub destination_device: Rc<DeviceSpec>,
    pub source_device: Rc<DeviceSpec>,
    pub name: String,
    pub fields: Vec<PacketFieldSpec>,
}
Expand description

Contains information about a VBus packet and its fields.

§Examples

use resol_vbus::{SpecificationFile, Specification, Language};

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

let packet_spec = spec.get_packet_spec(0x00, 0x0010, 0x7E11, 0x0100);
assert_eq!("00_0010_7E11_10_0100", packet_spec.packet_id);
assert_eq!(0, packet_spec.channel);
assert_eq!(0x0010, packet_spec.destination_address);
assert_eq!(0x7E11, packet_spec.source_address);
assert_eq!(0x0100, packet_spec.command);
assert_eq!("DFA", packet_spec.destination_device.name);
assert_eq!("DeltaSol MX [Regler]", packet_spec.source_device.name);
assert_eq!("DeltaSol MX [Regler]", packet_spec.name);

Fields§

§packet_id: String

A packet identifier.

§channel: u8

The VBus channel to packet was sent to.

§destination_address: u16

The destination VBus address the packet was sent to.

§source_address: u16

The source VBus address to packet was send from.

§command: u16

The VBus command of the packet.

§destination_device: Rc<DeviceSpec>

The DeviceSpec containing information about the destination VBus device.

§source_device: Rc<DeviceSpec>

The DeviceSpec containing information about the source VBus device.

§name: String

The name of the packet, containing channel, source and optionally destination names.

§fields: Vec<PacketFieldSpec>

The fields contained in the frame payload of the VBus packet.

Implementations§

Source§

impl PacketSpec

Source

pub fn get_field_spec_position(&self, id: &str) -> Option<usize>

Get the position of a PacketFieldSpec by its field ID.

Source

pub fn get_field_spec_by_position(&self, pos: usize) -> &PacketFieldSpec

Get a PacketFieldSpec by its position.

Source

pub fn get_field_spec(&self, id: &str) -> Option<&PacketFieldSpec>

Get a PacketFieldSpec by its field ID.

Trait Implementations§

Source§

impl Debug for PacketSpec

Source§

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

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