Skip to main content

dlms_cosem_rs/
lib.rs

1#![no_std]
2#![forbid(unsafe_code)]
3#![deny(missing_docs)]
4// Everything in this crate faces the network before any key has been checked, so the
5// ways a decoder can abort the process are denied outright rather than reviewed.
6#![deny(
7    clippy::panic,
8    clippy::unwrap_used,
9    clippy::expect_used,
10    clippy::todo,
11    clippy::unimplemented,
12    clippy::mem_forget,
13    clippy::exit
14)]
15#![warn(clippy::pedantic)]
16// A test is allowed to abort: that is what a failing assertion is.
17#![cfg_attr(test, allow(clippy::unwrap_used, clippy::panic, clippy::expect_used))]
18// Bounds-checked indexing and checked arithmetic are the deeper hygiene: every site in
19// this crate is guarded by a preceding length check, but the lints cannot see that, so
20// they live behind `--cfg dlms_audit`, which CI turns on for an audit pass. A cfg rather
21// than a feature, so `--all-features` and docs.rs never trip over them.
22#![cfg_attr(dlms_audit, warn(clippy::indexing_slicing, clippy::arithmetic_side_effects))]
23#![allow(
24    clippy::missing_errors_doc,
25    clippy::module_name_repetitions,
26    clippy::must_use_candidate,
27    clippy::similar_names,
28    clippy::wildcard_imports,
29    clippy::match_same_arms,
30    clippy::cast_possible_truncation,
31    clippy::cast_sign_loss,
32    clippy::cast_possible_wrap,
33    clippy::cast_lossless,
34    clippy::doc_markdown,
35    clippy::redundant_closure_for_method_calls,
36    clippy::needless_lifetimes,
37    clippy::many_single_char_names,
38    clippy::struct_field_names
39)]
40#![doc = include_str!("../README.md")]
41
42#[cfg(feature = "alloc")]
43extern crate alloc;
44
45#[cfg(feature = "std")]
46extern crate std;
47
48/// Recipes for the things people actually do with this crate.
49///
50/// Every example here is compiled — and, where it needs no socket, run — as a doctest,
51/// so a snippet that stops compiling fails the build rather than quietly misleading
52/// somebody. That is the whole value of the page, and it is also why the module is
53/// gated: a recipe reaches for the P1 reader and the well-known OBIS names, and a
54/// doctest cannot be conditional on a feature the way a function can. Documenting a
55/// recipe that will not compile in the reader's own configuration is exactly the kind of
56/// quietly-wrong documentation the compilation is meant to prevent.
57///
58/// `docs.rs` builds with every feature, so the published documentation always has it.
59#[cfg(all(
60    feature = "std",
61    feature = "client",
62    feature = "server",
63    feature = "hdlc",
64    feature = "wrapper",
65    feature = "p1",
66    feature = "suite0",
67    feature = "obis-names",
68))]
69#[doc = include_str!("../site/includes/cookbook.md")]
70pub mod cookbook {}
71
72pub mod codec;
73
74pub mod acse;
75pub mod ber;
76pub mod cosem;
77pub mod security;
78pub mod transport;
79pub mod xdlms;
80
81#[cfg(feature = "client")]
82pub mod client;
83#[cfg(feature = "server")]
84pub mod server;
85
86pub mod axdr;
87pub mod obis;
88
89pub use codec::{Error, ErrorKind, Reader, Result, SliceWriter, Writer};
90pub use obis::Obis;
91pub use xdlms::Apdu;