# SensorML ๐ฐ๏ธ
[](https://crates.io/crates/sensorml)
[](https://docs.rs/sensorml)


A minimalist, testable Rust crate for parsing and serializing SensorML documents in XML and JSON. Designed for integration with mapping layers, adapters, and future transformation pipelines.
## โจ Features
- Parse SensorML from XML and JSON
- Serialize SensorML to XML and JSON
- Validate sensor references and ISO 8601 timestamps
- High test coverage and mutation resistance
- Depends only on `serde`, `quick-xml`, and `chrono`
## ๐ฆ Installation
Add to your `Cargo.toml`:
```toml
sensorml = "0.1"
```
## ๐ Example
```rust
use sensorml::model::{SensorMLDocument, Sensor, Observation};
use sensorml::format::json;
let doc = SensorMLDocument {
sensors: vec![Sensor {
id: "sensor-1".into(),
sensor_type: "temperature".into(),
unit: "Celsius".into(),
description: Some("Outdoor sensor".into()),
}],
observations: vec![Observation {
sensor_id: "sensor-1".into(),
timestamp: "2025-10-11T10:00:00Z".into(),
value: "18.5".into(),
}],
};
let json = json::serialize_to_json(&doc)?;
let parsed = json::parse_from_json(&json)?;
parsed.validate()?; // checks sensor references and timestamp format
```
## ๐งช Testing
```bash
cargo test
cargo tarpaulin
cargo mutants
```
## ๐ License
MIT ยฉ 2025 Egon Kastelijn