Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sintef/sindit-senml
Rust implementation of the SenML RFC8428 proposed standard
https://github.com/sintef/sindit-senml
digital-twins iot rust senml sensor-data sindit
Last synced: 6 days ago
JSON representation
Rust implementation of the SenML RFC8428 proposed standard
- Host: GitHub
- URL: https://github.com/sintef/sindit-senml
- Owner: SINTEF
- License: apache-2.0
- Created: 2023-11-21T16:37:08.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-14T07:04:26.000Z (10 months ago)
- Last Synced: 2024-04-29T16:09:56.991Z (6 months ago)
- Topics: digital-twins, iot, rust, senml, sensor-data, sindit
- Language: Rust
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SINDIT SenML
Rust implementation of the [SenML RFC8428](https://www.rfc-editor.org/rfc/rfc8428) proposed standard.
SenML (Sensor Markup Language) is a format for representing sensor data.
*Only the JSON representation is implemented.*
## Examples:
```rust
use sindit_senml::parse_json;let json_str = r#"[{"n": "temperature", "v": 42.0}]"#;
let records = parse_json(json_str, None).unwrap();
assert_eq!(records[0].name, "temperature");
assert_eq!(records[0].get_float_value(), Some(42.0));
``````rust
use sindit_senml::SenMLResolvedRecord;let record = SenMLResolvedRecord {
name: "temperature".to_string(),
unit: Some("Cel".to_string()),
value: Some(sindit_senml::SenMLValueField::FloatingPoint(42f64)),
sum: None,
time: chrono::DateTime::::from_timestamp(1234567890, 0).unwrap(),
update_time: None,
base_version: None,
extra_fields: None,
};
let json = serde_json::to_string(&vec![record]).unwrap();
assert_eq!(
json,
r#"[{"n":"temperature","u":"Cel","v":42,"t":1234567890}]"#
);
```