Expand description
§nmea-0183-rs
Bidirectional NMEA 0183 parser/encoder with AIS decoding and transponder-message encoding.
§Architecture
raw line ──→ parse_frame() ──→ NmeaFrame { prefix, talker, sentence_type, fields }
│
┌──────────────┼──────────────┐
▼ ▼ ▼
$ + known $ + unknown ! AIVDM/AIVDO AIS app sentences
│ │ │ │
▼ ▼ ▼ ▼
Typed struct Raw fields AisMessage enum AIS sentence struct§Public API
parse_frame/encode_frame— device-compatible frame APIs (always available)parse_frame_strict/validate_sentence/encode_frame_strict— strict frame-envelope APIs (always available)NmeaSentence— dispatch enum for all typed NMEA sentences (requires an NMEA feature)NmeaEncodable— trait providing compatible and strict wire encoding (requires an NMEA feature)ais— AIS decoder, transponder-message encoder, and!-prefixed AIS application sentences (requiresais,abm, orbbm)
NmeaFrame::to_sentence() re-encodes envelope data, including tag blocks,
while normalizing checksums and CRLF. Keep the original line for exact bytes.
NmeaSentence and ais::sentences::AisSentence also expose compatible and
strict encoding; their Unknown variants own and preserve the captured envelope.
Typed variants require the original frame to retain tags and the original talker.
NMEA and ABM/BBM structs implement Default for construction with partial data.
Their field parsers return Self directly; missing or malformed fields remain optional.
With ais, AisParser::decode() distinguishes ignored frames,
pending fragments, messages and AisDecodeError through a Result.
Use one parser per physical source.
Position timestamps use ais::messages::PositionTimestamp, preserving the
unavailable, manual-input, dead-reckoning and inoperative states.
§Partial construction and enum encoding
use nmea_0183_rs::{NmeaSentence, parse_frame};
use nmea_0183_rs::nmea::Dpt;
let value = NmeaSentence::Dpt(Dpt { depth: Some(4.1), ..Default::default() });
let output = value.to_sentence_strict("SD")?;
assert_eq!(NmeaSentence::parse(&parse_frame(&output)?), value);Strict validation covers the shared frame envelope. It does not validate every formatter’s field semantics, serial transport settings, transmission timing, or multipart reassembly outside the AIS parser.
§Features
nmea(default): all 93 standard NMEA sentence typesnmea_proprietary(default) — all 16 proprietary NMEA sentence typesais(default) — decoding for all numeric AIS Types 1-27, encoder support for Types 1/2/3, 4, 5, 9, 11, 12, 14, 18, 19, 21, 24 and 27, plus ABM, BBM and VSD sentences- Release 0.9.5 adds STN, XTR, ZDL, and ZFO: 101 NMEA formatters (85 standard, 16 proprietary) and 1076 passing all-features tests, including doctests
- Release 0.9.6 adds ALM, FSI, MSK, and MSS: 105 NMEA formatters (89 standard, 16 proprietary) and 1113 passing all-features tests, including doctests
- Release 0.9.7 adds HRM, NAK, ROR, and SPW, bringing coverage to 109 NMEA formatters (93 standard, 16 proprietary) and 1242 passing all-features tests, including doctests
dbs,dbt,dpt, … — individual sentence types
Re-exports§
pub use nmea::NmeaSentence;pub use nmea::NmeaEncodable;
Modules§
- ais
- AIS (Automatic Identification System) message decoding and application-layer sentences.
- nmea
- NMEA 0183 sentence parsing and encoding.
Structs§
- Nmea
Frame - A parsed NMEA 0183 frame with references into the original input.
Enums§
- Compliance
Error - Errors reported by strict sentence validation.
- Encode
Error - Errors from encoding (invalid frame parts or field values).
- Frame
Error - Errors from frame-level parsing (checksum, delimiters, tag blocks).
- Strict
Encode Error - Errors returned while building and strictly validating an encoded sentence.
Constants§
- MAX_
SENTENCE_ LEN - Maximum NMEA 0183 sentence length, including the leading delimiter and CRLF.
Functions§
- encode_
frame - Encode fields into a valid NMEA 0183 sentence string.
- encode_
frame_ strict - Encode a sentence and require the resulting wire representation to satisfy the strict frame rules.
- parse_
frame - Parse a raw NMEA 0183 line using device-compatible framing rules.
- parse_
frame_ strict - Parse a complete sentence only when it satisfies the strict wire rules.
- validate_
sentence - Validate a complete NMEA 0183 sentence using the strict wire rules.