I need to interact with a proprietary GPS logger that sends sentences like:
$PMTK182,8,0001F800,FFFFFFFFFFFFFF…FFFFF*52
Now I could wrap the parse_sentence function and handle those proprietary functions in the wrapper but I would have to duplicate code like checksum verification.
Possible solutions:
- Include the whole sentence as a struct field in
ParseError::UnsupportedSentenceType so that wrapper can attempt to handle it after running parse_sentence.
- Return
Ok(ParsedMessage::Proprietary(String)) from parse_sentence instead of ParseError::UnsupportedSentenceType.
- Factor out the
verify_and_strip_checksum function and make it public.
- Add
NmeaParserFull<ProprietaryMessagesType> (NmeaParser would become NmeaParserFull<()>) and a method like NmeaParserFull::register_parser_for_prefix<H>(prefix: &str, handler: H) where H: Fn(&str) -> Option<ProprietaryMessagesType>
I need to interact with a proprietary GPS logger that sends sentences like:
Now I could wrap the
parse_sentencefunction and handle those proprietary functions in the wrapper but I would have to duplicate code like checksum verification.Possible solutions:
ParseError::UnsupportedSentenceTypeso that wrapper can attempt to handle it after runningparse_sentence.Ok(ParsedMessage::Proprietary(String))fromparse_sentenceinstead ofParseError::UnsupportedSentenceType.verify_and_strip_checksumfunction and make it public.NmeaParserFull<ProprietaryMessagesType>(NmeaParserwould becomeNmeaParserFull<()>) and a method likeNmeaParserFull::register_parser_for_prefix<H>(prefix: &str, handler: H) where H: Fn(&str) -> Option<ProprietaryMessagesType>