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//! let (record, _cert, _sig) = client
46//! .get_record("1234567890723", "controlMeasuresV1", 1)
47//! .await?;
48//! println!("{}", record.url);
49//! # Ok(())
50//! # }
51//! ```
52
53#![expect(
54 clippy::large_enum_variant,
55 reason = "a pedantic style lint this crate does not adopt"
56)]
57
58pub mod directory;
59pub mod error;
60pub mod models;
61pub mod spec_version;
62pub mod transport;
63
64#[cfg(feature = "client")]
65pub mod client;
66
67#[cfg(feature = "server")]
68pub mod server;
69
70pub use error::Error;