Function teleinfo_nom::get_message
source · pub fn get_message<T: Read>(
source: &mut T,
leftover: String
) -> Result<(String, TeleinfoMessage)>
Expand description
Read message from an readable object source
, with leftover
being the unparsed string
from a previous call
Returns a tuple with to be parsed in a next call string as leftover
and the first found TeleinfoMessage
Example
use std::fs::File;
// Could be a serial port with serialport crate
let mut stream = File::open("assets/stream_standard_raw.txt").unwrap();
let (remain, msg1) = teleinfo_nom::get_message(&mut stream, "".to_string()).unwrap();