sensor-db-derive
#[derive(SensorData)] for sensor-db,
an append-only sensor database for NOR flash on embedded devices.
This crate is an implementation detail of sensor-db's derive feature. Reach
for it through that feature rather than depending on it directly:
= { = "0.1", = ["derive"] }
= { = "0.8", = ["derive"] }
use SensorData;
use ;
The macro emits the SensorData impl and nothing else. id and version
accept any constant expression, so the central ID module that actually prevents
collisions works directly (#[sensor(id = ids::TEMPERATURE)]); version
defaults to the trait's 0, and crate = ... covers a renamed sensor_db.
Two things it deliberately does not do:
- It does not emit the zerocopy derives. A derive macro cannot add
attributes to the item it is applied to, and zerocopy's derives expand to
absolute
::zerocopy::paths — so a re-export does not reach a downstream crate, andzerocopymust be a direct dependency either way. Injecting them would make that requirement invisible and its absence inscrutable. - It does not check for padding.
zerocopy'sIntoBytesderive already rejects a padded type and reports the exact number of wasted bytes, which is a better diagnostic than anything this macro could add.
Full documentation, including the wire format a payload is written in, lives with the parent crate: https://docs.rs/sensor-db.
License
Dual-licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.