CCSDS NDM
A high-performance, type-safe library for parsing and generating CCSDS Navigation Data Messages (NDM) in both KVN (Key-Value Notation) and XML formats.
This crate is designed for mission-critical space applications where correctness, performance, and adherence to standards are paramount.
Key Features
- Comprehensive Support: Full support for OPM, OMM, OEM, OCM, CDM, TDM, RDM, AEM, APM, and ACM messages.
- Format Agnostic: Seamlessly convert between KVN and XML formats.
- Type Safety: Strictly typed units (e.g.,
km,deg,s) prevent physical unit errors. - High Performance Parsing: Utilizes
winnowandquick-xmlfor efficient, low-allocation parsing. - Ergonomic Construction: Uses the builder pattern (via the
boncrate) for safe and easy message creation. - Standard Compliant: Validates messages against CCSDS 502.0-B-3 and related standards.
Architecture
The library is organized around a few core concepts:
NdmTrait: The unifying interface for all message types. It defines the standardto_kvn,from_kvn,to_xml, andfrom_xmlmethods.MessageTypeEnum: A container that holds any valid NDM. This is the primary return type when parsing files with unknown contents (auto-detection).- Strong Typing: All physical quantities (Distance, Velocity, Mass, etc.) are wrapped in the
UnitValuestruct, ensuring that units are always tracked and validated.
Quick Start
1. Parse any NDM file (auto-detection)
The library automatically detects whether the input is KVN or XML and what message type it contains.
use ;
let ndm = from_file.unwrap;
match ndm
2. Parse a specific message type
If you know the message type in advance, you can parse it directly:
use Opm;
use Ndm;
// Parses strict KVN for OPM
let opm = from_kvn.unwrap;
3. Generate a message using the Builder Pattern
Creating messages from scratch is safe and verbose-free using the builder() methods.
use ;
use ;
use ;
use Ndm;
let opm = builder
.version
.header
.body
.build;
// Convert to KVN string
println!;
4. Serialize to KVN or XML
use ;
let ndm = from_file.unwrap;
// Serialize to string
let kvn_string = ndm.to_kvn.unwrap;
let xml_string = ndm.to_xml.unwrap;
// Write to file
ndm.to_xml_file.unwrap;
License
MPL-2.0