Expand description
§openadr — OpenADR 3.1 in Rust
An implementation of the OpenADR 3 demand-response protocol: a VTN server, a VEN runtime and a typed client, over a shared wire model and a deterministic domain core — one crate, sliced with Cargo features.
OpenADR is how a utility asks flexible load to move. A VTN publishes programmes and events; a VEN — a charge point, a battery, a heat pump — reads them, acts, and reports back. Narrative documentation, including an introduction to the protocol itself, is at https://hupe1980.github.io/openadr.
§Layers
| Module | Feature | What |
|---|---|---|
model | always on (no_std + alloc) | wire types, newtypes with invariants, spec sentinels |
schema | always on | payload typing from the Alliance enumeration schemas |
core | always on | interval expansion, timeline, object privacy, report scheduling |
client | client | business-logic and VEN HTTP clients, role-checked at compile time |
ven | ven | the VEN loop: registration, event sync, timeline, report scheduling |
conformance | conformance | a black-box suite that measures any VTN against the specification |
vtn | vtn | axum VTN server, storage, authentication, the notification outbox |
webhook | webhook-signature | the webhook signature scheme, both ends of it (no_std) |
mqtt | mqtt | shared MQTT broker transport |
discovery | always on; mdns for the socket | finding a local VTN over mDNS/DNS-SD, both ends |
Storage backends are sqlite and postgres; authentication backends are internal-auth and
external-auth; push transports are webhook and mqtt. Every flag is read by a cfg.
A subscriber can enable webhook-signature or mqtt on its own. TLS roles use the process
provider, with a ring fallback when the default tls-ring feature is enabled.
§Serving
use openadr::vtn::{Vtn, store::MemoryStorage};
let vtn = Vtn::builder().storage(MemoryStorage::shared()).build();
vtn.serve("0.0.0.0:3000").await?;Vtn::builder is a typestate: build() exists only once a storage backend
has been given, so a VTN with nowhere to put an event is a compile error. Without an
authenticator it serves unauthenticated readers, which is read-only by construction — every
write requires a scope, and an anonymous principal holds none.
§Reading a schedule
use openadr::prelude::*;
// Resolve an event's declared timing into absolute windows: inherited periods, the `now`
// sentinel, unbounded durations, and multi-value payloads that subdivide their interval.
let intervals = IntervalExpander::at(Timestamp::now()).expand(event)?;
// Or the whole sequence, including the intervals the event never lists: a tariff that loops
// for ever, and a forecast whose structure is implied by its `intervalPeriod` alone.
let sequence = IntervalExpander::at(Timestamp::now()).sequence(event)?;core::Timeline then merges a programme’s concurrent events by priority, splitting the loser
around the winner so a long price curve resumes when a short curtailment ends.
ven::VenRuntime is that loop with registration, conditional polling and reporting around it.
§Spec version
SPEC_VERSION is the release this crate is written from. There is no 3.0 compatibility in the
wire model — 3.1 is not backwards compatible with it — and peers that bend the schema are served
by request/response adapters at the edge instead (see model::adapt).
§no_std
default-features = false yields a no_std + alloc build containing model, schema
and core — the layers an appliance-class VEN needs, and they build for
thumbv7em-none-eabihf and wasm32-unknown-unknown. no_std here means no operating system,
not no heap: the wire model is Strings and Vecs, so an allocator is assumed.
Modules§
- client
client - HTTP clients for the two roles.
- conformance
conformance - A black-box conformance suite for any OpenADR 3.1 VTN.
- core
- The domain core: deterministic, I/O-free, and shared by the VTN, the VEN and the tests.
- discovery
- mDNS/DNS-SD discovery of a local VTN.
- model
- The OpenADR 3.1 wire model.
- mqtt
mqtt - This crate’s MQTT 3.1.1 client, shared by the VTN’s publisher and the VEN’s subscriber.
- prelude
- Everything a typical user wants in scope.
- schema
- Payload typing: what values a payload type may carry, and what the specification says it means.
- ven
ven - The VEN runtime: registration, event synchronisation, a maintained timeline, and reporting.
- vtn
vtn - The VTN server.
- webhook
webhook-signature - The webhook signature scheme — both ends of it.
Structs§
- Missing
Crypto Provider clientorexternal-authormqttortlsorwebhook - No application provider was installed and the ring fallback is disabled.
Constants§
- DEFAULT_
BASE_ PATH - Default base path a VTN is mounted under (
/openadr3/3.1.0). - SPEC_
VERSION - The OpenADR specification release this crate is written from.
Functions§
- install_
crypto_ provider clientorexternal-authormqttortlsorwebhook - Ensure a provider is installed before constructing a TLS transport.