pub struct Specification { /* private fields */ }
Expand description
The Specification
type contains information about known devices and packets.
§Examples
use resol_vbus::{SpecificationFile, Specification, Language};
let spec = Specification::from_file(SpecificationFile::new_default(), Language::De);
let device_spec = spec.get_device_spec(0x00, 0x7E11, 0x0010);
assert_eq!("00_7E11", device_spec.device_id);
assert_eq!(0, device_spec.channel);
assert_eq!(0x7E11, device_spec.self_address);
assert_eq!(None, device_spec.peer_address);
assert_eq!("DeltaSol MX [Regler]", device_spec.name);
Implementations§
Source§impl Specification
impl Specification
Sourcepub fn from_file(file: SpecificationFile, language: Language) -> Specification
pub fn from_file(file: SpecificationFile, language: Language) -> Specification
Construct a Specification
from a SpecificationFile
and a Language
.
§Examples
use resol_vbus::{SpecificationFile, Specification, Language};
let spec = Specification::from_file(SpecificationFile::new_default(), Language::De);
// work with the spec...
Sourcepub fn get_device_spec(
&self,
channel: u8,
self_address: u16,
peer_address: u16,
) -> Rc<DeviceSpec>
pub fn get_device_spec( &self, channel: u8, self_address: u16, peer_address: u16, ) -> Rc<DeviceSpec>
Get a DeviceSpec
.
§Examples
use resol_vbus::{SpecificationFile, Specification, Language};
let spec = Specification::from_file(SpecificationFile::new_default(), Language::De);
let device_spec = spec.get_device_spec(0x00, 0x7E11, 0x0010);
assert_eq!("00_7E11", device_spec.device_id);
assert_eq!(0, device_spec.channel);
assert_eq!(0x7E11, device_spec.self_address);
assert_eq!(None, device_spec.peer_address);
assert_eq!("DeltaSol MX [Regler]", device_spec.name);
Sourcepub fn get_packet_spec(
&self,
channel: u8,
destination_address: u16,
source_address: u16,
command: u16,
) -> Rc<PacketSpec>
pub fn get_packet_spec( &self, channel: u8, destination_address: u16, source_address: u16, command: u16, ) -> Rc<PacketSpec>
Get a PacketSpec
.
§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);
Sourcepub fn get_packet_spec_by_id(&self, packet_id: PacketId) -> Rc<PacketSpec>
pub fn get_packet_spec_by_id(&self, packet_id: PacketId) -> Rc<PacketSpec>
Get a PacketSpec
.
§Examples
use resol_vbus::{SpecificationFile, Specification, Language, PacketId};
let spec = Specification::from_file(SpecificationFile::new_default(), Language::De);
let packet_spec = spec.get_packet_spec_by_id(PacketId(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);
Sourcepub fn fields_in_data_set<'a, T>(
&'a self,
data_set: &'a T,
) -> DataSetPacketFieldIterator<'a, T> ⓘ
pub fn fields_in_data_set<'a, T>( &'a self, data_set: &'a T, ) -> DataSetPacketFieldIterator<'a, T> ⓘ
Returns an iterator that iterates over all known packet fields in the data set.
§Examples
use resol_vbus::{Specification, DataSet};
fn print_fields(spec: &Specification, data_set: &DataSet) {
let mut last_data_index = None;
for field in spec.fields_in_data_set(data_set) {
let current_data_index = Some(field.data_index());
if last_data_index != current_data_index {
last_data_index = current_data_index;
println!("- {}: {}", field.packet_spec().packet_id, field.packet_spec().name);
}
println!(" - {}: {}", field.field_spec().field_id, field.field_spec().name);
}
}
Sourcepub fn fmt_timestamp<Tz>(
&self,
timestamp: &DateTime<Tz>,
) -> RawValueFormatter<'_>where
Tz: TimeZone,
pub fn fmt_timestamp<Tz>(
&self,
timestamp: &DateTime<Tz>,
) -> RawValueFormatter<'_>where
Tz: TimeZone,
Format a timestamp.
§Examples
use resol_vbus::{SpecificationFile, Specification, Language};
use resol_vbus::utils::utc_timestamp;
let fmt_localized_timestamp = |language| {
let spec = Specification::from_file(SpecificationFile::new_default(), language);
format!("{}", spec.fmt_timestamp(&utc_timestamp(1485688933)))
};
assert_eq!("29/01/2017 11:22:13", fmt_localized_timestamp(Language::En));
assert_eq!("29.01.2017 11:22:13", fmt_localized_timestamp(Language::De));
assert_eq!("29/01/2017 11:22:13", fmt_localized_timestamp(Language::Fr));
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Specification
impl !RefUnwindSafe for Specification
impl !Send for Specification
impl !Sync for Specification
impl Unpin for Specification
impl UnwindSafe for Specification
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more