[][src]Struct teleinfo_nom::TeleinfoMessage

pub struct TeleinfoMessage { /* fields omitted */ }

Representation of a full message from teleinfo

  • values is hashmap resolving index to TeleinfoValue
  • mode the mode of the messae as TeleinfoMode
  • valid whether the message is valid checksum wise

Methods

impl TeleinfoMessage[src]

pub fn get_message_type(&self) -> TeleinfoMessageType[src]

Return message type as TeleinfoMessageType

Example

use std::fs::File;
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_message_type(),teleinfo_nom::TeleinfoMessageType::Normal)

pub fn get_meter_type(&self) -> TeleinfoMeterType[src]

Return meter type as TeleinfoMeterType

Example

use std::fs::File;
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_meter_type(),teleinfo_nom::TeleinfoMeterType::TriPhase)

pub fn get_current_index(&self) -> String[src]

Return the index currently increasing

Example

use std::fs::File;
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_current_index(),"EASF03".to_string());
let mut stream = File::open("assets/stream_legacy_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_current_index(),"BBRHPJB".to_string())

pub fn get_billing_indices(&self) -> Vec<String>[src]

Return all relevant billing indices for the message

Example

use std::fs::File;
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_billing_indices(),vec![
       "EASF01".to_string(),
       "EASF02".to_string(),
       "EASF03".to_string(),
       "EASF04".to_string(),
       "EASF05".to_string(),
       "EASF06".to_string(),
       "EASF07".to_string(),
       "EASF08".to_string(),
       "EASF09".to_string(),
       "EASF10".to_string(),
   ]);
let mut stream = File::open("assets/stream_legacy_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_billing_indices(),vec![
"BBRHCJB".to_string(),
"BBRHPJB".to_string(),
"BBRHCJR".to_string(),
"BBRHPJR".to_string(),
"BBRHCJW".to_string(),
"BBRHPJW".to_string(),
])

pub fn get_value(&self, key: String) -> Option<&TeleinfoValue>[src]

Return a &TeleinfoValue as Option for key

Example

use std::fs::File;
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_value("EASF03".to_string()).unwrap().value,"000487131");
let mut stream = File::open("assets/stream_legacy_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_value("BBRHPJB".to_string()),Some(&teleinfo_nom::TeleinfoValue{value: "001012295".to_string(),
horodate: None }))

pub fn get_values(&self, keys: Vec<String>) -> Vec<(String, Option<String>)>[src]

Return a vector of tuples with (index,Option(value)) from a vector of indices to fetch

Example

use std::fs::File;
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_values(result.get_billing_indices()),
           vec![
           ("EASF01".to_string(),Some("004855593".to_string())),
           ("EASF02".to_string(),Some("014090959".to_string())),
           ("EASF03".to_string(),Some("000487131".to_string())),
           ("EASF04".to_string(),Some("001481464".to_string())),
           ("EASF05".to_string(),Some("000227596".to_string())),
           ("EASF06".to_string(),Some("000706363".to_string())),
           ("EASF07".to_string(),Some("000000000".to_string())),
           ("EASF08".to_string(),Some("000000000".to_string())),
           ("EASF09".to_string(),Some("000000000".to_string())),
           ("EASF10".to_string(),Some("000000000".to_string())),
           ]);
let mut stream = File::open("assets/stream_legacy_raw.txt").unwrap();
let (remain, result) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();
assert_eq!(result.get_values(result.get_billing_indices()),
           vec![
           ("BBRHCJB".to_string(),Some("001478389".to_string())),
           ("BBRHPJB".to_string(),Some("001012295".to_string())),
           ("BBRHCJR".to_string(),Some("000025098".to_string())),
           ("BBRHPJR".to_string(),Some("000006010".to_string())),
           ("BBRHCJW".to_string(),Some("000134553".to_string())),
           ("BBRHPJW".to_string(),Some("000213701".to_string())),
           ]);

Trait Implementations

impl Clone for TeleinfoMessage[src]

impl Debug for TeleinfoMessage[src]

impl PartialEq<TeleinfoMessage> for TeleinfoMessage[src]

impl StructuralPartialEq for TeleinfoMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.