[−][src]Crate ais
AIS parsing library, for reading AIS NMEA sentences
Given an NMEA stream, this library can extract various AIS message types in more detail.
Example:
use ais::{AisFragments, AisParser}; use ais::messages::AisMessage; // The line below is an NMEA sentence, much as you'd see coming out of an AIS decoder. let line = b"!AIVDM,1,1,,B,E>kb9O9aS@7PUh10dh19@;0Tah2cWrfP:l?M`00003vP100,0*01"; let mut parser = AisParser::new(); if let AisFragments::Complete(sentence) = parser.parse(line, true)? { // This sentence is complete, ie unfragmented assert_eq!(sentence.num_fragments, 1); // The data was transmitted on AIS channel B assert_eq!(sentence.channel, Some('B')); if let Some(message) = sentence.message { match message { AisMessage::AidToNavigationReport(report) => { assert_eq!(report.mmsi, 993692028); assert_eq!(report.name, "SF OAK BAY BR VAIS E"); // There are a ton more fields available here }, _ => panic!("Unexpected message type"), } } }
Re-exports
pub use errors::Result; |
pub use sentence::AisFragments; |
pub use sentence::AisParser; |
Modules
errors | Custom error types used by this crate |
messages | Specific AIS message types |
sentence | Handlers for AIS messages at the NMEA sentence layer |