energy_api/lib.rs
1#![deny(unsafe_code)]
2//! # energy-api
3//!
4//! Rust client and server bindings for the German energy market API-Webdienste
5//! (MaKo — Marktkommunikation).
6//!
7//! ## Module layout
8//!
9//! ```text
10//! energy_api
11//! ├── models/ OpenAPI/AsyncAPI types shared by all APIs
12//! ├── transport/ HTTP + mTLS builder, JWS sign/verify
13//! ├── directory/ Verzeichnisdienst — REST client, WebSocket client, server
14//! ├── client/ Electricity API clients (feature = "client")
15//! │ └── malo_ident LF and NB callback calls
16//! └── server/ Electricity API servers (feature = "server")
17//! ├── control_measures MSB and NB/LF receive handlers + axum router
18//! ├── malo_ident NB and LF receive handlers + axum router
19//! └── wim_order MSB receive handler (iMS Anmeldung) + NB callbacks
20//! ```
21//!
22//! ## Feature flags
23//!
24//! | Feature | Enables |
25//! |-------------|----------------------------------------------------------|
26//! | `client` | MaLo-Ident and directory HTTP clients (reqwest + rustls) |
27//! | `server` | Axum router factories for server implementations |
28//! | `websocket` | WebSocket subscription client (tokio-tungstenite) |
29//!
30//! Content signing (`transport::content_security`) and the directory JWS
31//! (`transport::jws`) are always compiled.
32//!
33//! ## Quick start
34//!
35//! ### Look up an endpoint via the directory
36//!
37//! ```no_run
38//! # #[cfg(feature = "client")]
39//! # async fn example() -> Result<(), energy_api::Error> {
40//! use energy_api::directory::DirectoryServiceClient;
41//! use url::Url;
42//!
43//! let base = Url::parse("https://verzeichnisdienst.example.de/")?;
44//! let client = DirectoryServiceClient::new_insecure(base)?;
45//! // The provider's EMT.API signature key, from the issuing Sub-CA.
46//! # let provider_key: energy_api::transport::jws::RecordVerifyingKey = todo!();
47//! let record = client
48//! .get_record("1234567890723", "controlMeasuresV1", 1, &[provider_key])
49//! .await?;
50//! println!("{}", record.url);
51//! # Ok(())
52//! # }
53//! ```
54
55#![expect(
56 clippy::large_enum_variant,
57 reason = "a pedantic style lint this crate does not adopt"
58)]
59
60pub mod directory;
61pub mod error;
62pub mod models;
63pub mod spec_version;
64pub mod transport;
65
66#[cfg(feature = "client")]
67pub mod client;
68
69#[cfg(feature = "server")]
70pub mod server;
71
72pub use error::Error;