Crate titanic

Source
Expand description

Parser for the GGA sentence of the NMEA 0183 protocol.

This parser accepts data as described here.

§Setup

Add this to Cargo.toml:

[dependencies]
titanic = "0.1.0"

Then put this in your crate root:

extern crate titanic;

§Usage

GgaParser can be used like an Iterator. Calling next() on GgaParser blocks until it finds '$', reaches EOF or an I/O error occurs. '$' signals the beginning of a new sentence. If the new sentence is of the type GGA, it will be parsed if possible. Parser iterates over Result<GgaSentence, ParseError>.

EOF signals the end of the iterator.

use titanic::GgaParser;

let parser = GgaParser::new(data).unwrap();

for gga in parser {
    let gga = gga.unwrap();
    println!(
       "Time: {}, we are here: {}°, {}°",
       gga.utc.format("%H:%M:%S"),
       gga.lat.unwrap(),
       gga.long.unwrap()
   );
}
// Prints "Time: 14:22:12, we are here: -19.94903°, -69.633605°"

Re-exports§

pub use parser::GgaParser;
pub use parser::GgaSentence;

Modules§

err
All errors that can happen while parsing can be found here.
parser
This module provides a parser for the GGA sentence of the NMEA 0183 protocol.

Macros§

accept
Accept only the given TokenKind.
expect
Expect the given TokenKind.
try_err
Like the try! macro only that this returns Some(Err(err)) instead of Err(err).
try_some
Like the try! macro, but only works on Result<Option<_>, _> and returns Some(Err(err)) instead of Err(err).