pub struct DataRecord<'a> {
pub data_record_header: DataRecordHeader<'a>,
pub data: Data<'a>,
pub raw_bytes: &'a [u8],
}Fields§
§data_record_header: DataRecordHeader<'a>§data: Data<'a>§raw_bytes: &'a [u8]Raw bytes encompassing this data record
Implementations§
Source§impl DataRecord<'_>
impl DataRecord<'_>
Sourcepub fn value(&self) -> Option<&DataType<'_>>
pub fn value(&self) -> Option<&DataType<'_>>
Returns the parsed value carried by this record.
Examples found in repository?
examples/parse_data_records.rs (line 14)
3fn main() -> Result<(), DataRecordError> {
4 // Application-layer records only: no wired/wireless frame or CI/TPL header.
5 let data = [
6 0x03, 0x13, 0x15, 0x31, 0x00, // Volume: 12_565 x 10^-3 m³
7 0x02, 0x5A, 0xD7, 0x04, // Flow temperature: 1_239 x 10^-1 °C
8 ];
9
10 for (index, record) in parse_data_records(&data).enumerate() {
11 let record = record?;
12
13 println!("Record {}", index + 1);
14 println!(" value: {:?}", record.value());
15 if let Some(value_information) = record.value_information() {
16 println!(" labels: {:?}", value_information.labels);
17 println!(" scale: 10^{}", value_information.decimal_scale_exponent);
18 println!(" units: {:?}", value_information.units);
19 }
20 println!(" raw bytes: {:02X?}", record.raw_bytes());
21 }
22
23 Ok(())
24}Sourcepub fn data_information(&self) -> Option<&DataInformation>
pub fn data_information(&self) -> Option<&DataInformation>
Returns the processed data information (DIF and DIFE fields).
Sourcepub fn value_information(&self) -> Option<&ValueInformation>
pub fn value_information(&self) -> Option<&ValueInformation>
Returns the processed value information (VIF and VIFE fields).
Examples found in repository?
examples/parse_data_records.rs (line 15)
3fn main() -> Result<(), DataRecordError> {
4 // Application-layer records only: no wired/wireless frame or CI/TPL header.
5 let data = [
6 0x03, 0x13, 0x15, 0x31, 0x00, // Volume: 12_565 x 10^-3 m³
7 0x02, 0x5A, 0xD7, 0x04, // Flow temperature: 1_239 x 10^-1 °C
8 ];
9
10 for (index, record) in parse_data_records(&data).enumerate() {
11 let record = record?;
12
13 println!("Record {}", index + 1);
14 println!(" value: {:?}", record.value());
15 if let Some(value_information) = record.value_information() {
16 println!(" labels: {:?}", value_information.labels);
17 println!(" scale: 10^{}", value_information.decimal_scale_exponent);
18 println!(" units: {:?}", value_information.units);
19 }
20 println!(" raw bytes: {:02X?}", record.raw_bytes());
21 }
22
23 Ok(())
24}Sourcepub fn raw_bytes(&self) -> &[u8] ⓘ
pub fn raw_bytes(&self) -> &[u8] ⓘ
Returns all raw bytes consumed by this record.
Examples found in repository?
examples/parse_data_records.rs (line 20)
3fn main() -> Result<(), DataRecordError> {
4 // Application-layer records only: no wired/wireless frame or CI/TPL header.
5 let data = [
6 0x03, 0x13, 0x15, 0x31, 0x00, // Volume: 12_565 x 10^-3 m³
7 0x02, 0x5A, 0xD7, 0x04, // Flow temperature: 1_239 x 10^-1 °C
8 ];
9
10 for (index, record) in parse_data_records(&data).enumerate() {
11 let record = record?;
12
13 println!("Record {}", index + 1);
14 println!(" value: {:?}", record.value());
15 if let Some(value_information) = record.value_information() {
16 println!(" labels: {:?}", value_information.labels);
17 println!(" scale: 10^{}", value_information.decimal_scale_exponent);
18 println!(" units: {:?}", value_information.units);
19 }
20 println!(" raw bytes: {:02X?}", record.raw_bytes());
21 }
22
23 Ok(())
24}pub fn get_size(&self) -> usize
Trait Implementations§
Source§impl<'a> Clone for DataRecord<'a>
impl<'a> Clone for DataRecord<'a>
Source§fn clone(&self) -> DataRecord<'a>
fn clone(&self) -> DataRecord<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for DataRecord<'a>
impl<'a> Debug for DataRecord<'a>
Source§impl<'a> PartialEq for DataRecord<'a>
impl<'a> PartialEq for DataRecord<'a>
impl<'a> StructuralPartialEq for DataRecord<'a>
Source§impl<'a> TryFrom<&'a [u8]> for DataRecord<'a>
impl<'a> TryFrom<&'a [u8]> for DataRecord<'a>
Source§impl<'a> TryFrom<(&'a [u8], &'a LongTplHeader)> for DataRecord<'a>
impl<'a> TryFrom<(&'a [u8], &'a LongTplHeader)> for DataRecord<'a>
Auto Trait Implementations§
impl<'a> Freeze for DataRecord<'a>
impl<'a> RefUnwindSafe for DataRecord<'a>
impl<'a> Send for DataRecord<'a>
impl<'a> Sync for DataRecord<'a>
impl<'a> Unpin for DataRecord<'a>
impl<'a> UnsafeUnpin for DataRecord<'a>
impl<'a> UnwindSafe for DataRecord<'a>
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