diff --git a/Cargo.toml b/Cargo.toml index ea6e9cb..3bcb51d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ arrayvec = {version = "0.7.2", default-features = false} chrono = {version = "0.4.19", default-features = false} heapless = "0.7.15" nom = {version = "7.1.1", default-features = false} +parse-display = {version = "0.6.0", default-features = false} # we include num-traits only when `std` is not enabled # because of `fract()` and `trunc()` methods diff --git a/src/parse.rs b/src/parse.rs index 4cbf0dc..50d2262 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -7,6 +7,7 @@ use nom::{ sequence::preceded, IResult, }; +use parse_display::{Display, FromStr}; use crate::{sentences::*, Error, SentenceType}; @@ -30,6 +31,8 @@ use crate::{sentences::*, Error, SentenceType}; pub const SENTENCE_MAX_LEN: usize = 102; /// A known and parsable Nmea sentence type. +#[derive(Display)] +#[display("${talker_id},{message_id},{data}*{checksum}")] pub struct NmeaSentence<'a> { pub talker_id: &'a str, pub message_id: SentenceType,