Skip to main content

energy_api/
lib.rs

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