| Crates.io | csdif-core |
| lib.rs | csdif-core |
| version | 0.1.3 |
| created_at | 2025-10-27 10:23:22.997096+00 |
| updated_at | 2025-10-27 15:18:26.663539+00 |
| description | Core library for modeling, validating, and transforming CSDIF data |
| homepage | |
| repository | https://codeberg.org/meten-natuurlijk/csdif-core |
| max_upload_size | |
| id | 1902576 |
| size | 2,245,502 |
= csdif-core :author: Egon Kastelijn :source-highlighter: coderay :icons: font :toc: left :toclevels: 2
๐ฆ Core library for modeling, validating, and transforming CSDIF data.
== ๐ง Purpose
This crate provides the reusable core logic for working with CSDIF data structures. It is designed to be used by multiple adapters, including:
csdif-cli โ command-line exportercsdif-api โ web-based API serviceIt implements the format and validation layer of the CSDIF RFC, but does not include any I/O, CLI, or web-specific logic.
== ๐งฑ Design Pattern
This crate represents the core hexagon in a hexagonal architecture (Ports & Adapters). It contains:
Sensor, Observation, Location, CsdifDocument)validate_document)Adapters such as CLI or web-API interact with this crate via public interfaces, but this crate remains unaware of its consumers.
== ๐ฆ Features
== Data Processing Flow
Incoming CSDIF data passes through the following stages:
|=== | Step | Description | Responsible Component | Extensibility
| 1. Transport (Inbound) | Data arrives via HTTP, MQTT, File, etc. | csdif-api, csdif-mqtt, csdif-cli | Add new transport modules
| 2. Format Decoding | Raw data is decoded from JSON, XML, CSV, etc. | csdif-core::format | Implement new FormatDecoder traits
| 3. Schema Interpretation | Data is interpreted according to the initiative-specific schema | csdif-mapper-* | Implement InitiativeMapper trait
| 4. Mapping to SensorML | Data is converted into the internal SensorML domain model | csdif-mapper-* + sensorml | Add new mappers per initiative
| 5. Validation & Processing | SensorML document is validated and optionally enriched | sensorml | Extend domain validation via traits
| 6. Mapping to External Schema (optional) | SensorML is transformed into a target schema if needed | csdif-core::mapper::* | Implement SchemaExporter trait
| 7. Format Encoding | Data is encoded into JSON, XML, CSV, etc. | csdif-core::format | Implement FormatEncoder traits
| 8. Transport (Outbound) | Data is sent via HTTP, MQTT, File, etc. | csdif-api, csdif-mqtt, csdif-cli | Add new transport modules |===
This layered architecture ensures that new formats, transports, or initiative-specific schemas can be added without modifying the core logic. Each layer is pluggable and testable in isolation.
== ๐งช Testing Philosophy
unwrap, ?, or panic! allowed== ๐ License
All source files include:
== ๐ Usage
Add to your Cargo.toml:
Or use crates.io once published:
Then in your code:
== ๐ Related Crates
csdif-cli: CLI tool for exporting and validating CSDIF documentscsdif-api: Web service exposing CSDIF validation and transformation endpoints