Skip to main content

zerodds_coap_bridge/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3
4//! Crate `zerodds-coap-bridge`. Safety classification: **STANDARD**.
5//!
6//! CoAP (RFC 7252) Wire-Codec + Reliability + Discovery + Bridge —
7//! pure-Rust `no_std + alloc`, `forbid(unsafe_code)`. Implementiert
8//! neben dem reinen Wire-Codec auch alle CoAP-Begleit-Schichten:
9//! Reliability/Congestion-Control (§4.2-§4.7), Request/Response-
10//! Matching (§5.3), Block-Wise-Transfer (RFC 7959), Resource-Discovery
11//! im CoRE-Link-Format (RFC 6690), Observe-Registry (RFC 7641),
12//! Multicast-Diskovery, Caching/Proxying (§5.6 + §5.7), DTLS-Mode-
13//! Marker (§9) und einen Bidirectional-CoAP↔DDS-Topic-Bridge.
14//!
15//! Spec-Referenzen:
16//!
17//! - **RFC 7252** — CoAP (Constrained Application Protocol).
18//! - **RFC 7641** — Observing Resources in CoAP.
19//! - **RFC 7959** — Block-Wise Transfer.
20//! - **RFC 6690** — CoRE-Link-Format.
21//!
22//! ## Schichten-Position
23//!
24//! Layer 5 — Bridges. Substrat fuer DDS↔IoT-Endpoint-Mapping
25//! (Constrained-Devices, OPC-UA-PubSub-Mapping, ROS-2-on-Constrained-
26//! Bridges).
27//!
28//! ## Public API (Stand 1.0.0-rc.1)
29//!
30//! - [`CoapMessage`] / [`CoapCode`] / [`MessageType`] — Message-Modell
31//!   (§3 + §12.1).
32//! - [`encode`] / [`decode`] / [`CodecError`] — Wire-Codec.
33//! - [`CoapOption`] / [`OptionNumber`] / [`OptionValue`] — Options
34//!   mit Delta-Encoding + Extended-Length (§3.1, §5.10).
35//! - [`BlockOption`] / [`BlockValue`] / [`BlockReassembler`] /
36//!   [`BlockError`] — Block-Wise-Transfer (RFC 7959).
37//! - [`CoreLink`] / [`encode_links`] / [`decode_links`] — Resource-
38//!   Discovery (RFC 6690).
39//! - [`OBSERVE_OPTION_NUMBER`] / [`ObserveRegistry`] /
40//!   [`ObserverEntry`] — RFC 7641 Observer-State.
41//! - [`PendingConfirmable`] / [`ReliabilityTracker`] / [`TickOutput`] /
42//!   [`ACK_TIMEOUT_MS`] / [`MAX_RETRANSMIT`] — Reliability §4.
43//! - [`CoapDdsBridge`] / [`BridgeOp`] / [`BridgeError`] /
44//!   [`map_method`] / [`parse_dds_path`] — CoAP↔DDS-Topic-Mapping.
45//!
46//! ## Beispiel
47//!
48//! ```rust
49//! use zerodds_coap_bridge::{decode, encode, CoapCode, CoapMessage, MessageType};
50//!
51//! let msg = CoapMessage {
52//!     version: 1,
53//!     message_type: MessageType::Confirmable,
54//!     token: Vec::new(),
55//!     code: CoapCode::GET,
56//!     message_id: 0xBEEF,
57//!     options: Vec::new(),
58//!     payload: Vec::new(),
59//! };
60//!
61//! let wire = encode(&msg).expect("encode");
62//! let decoded = decode(&wire).expect("decode");
63//! assert_eq!(decoded.code, CoapCode::GET);
64//! ```
65
66#![forbid(unsafe_code)]
67#![warn(missing_docs)]
68#![allow(
69    clippy::expect_used,
70    clippy::unwrap_used,
71    clippy::panic,
72    clippy::print_stderr,
73    clippy::print_stdout,
74    clippy::field_reassign_with_default,
75    clippy::manual_flatten,
76    clippy::collapsible_if,
77    clippy::empty_line_after_doc_comments,
78    clippy::approx_constant,
79    clippy::unreachable,
80    clippy::uninlined_format_args,
81    clippy::drop_non_drop,
82    clippy::useless_conversion,
83    clippy::manual_strip,
84    missing_docs
85)]
86
87extern crate alloc;
88
89pub mod blockwise;
90pub mod bridge;
91pub mod caching_proxy;
92pub mod codec;
93pub mod core_link;
94#[cfg(feature = "daemon")]
95pub mod daemon;
96pub mod dtls;
97pub mod matching;
98pub mod message;
99pub mod method_props;
100pub mod multicast;
101pub mod observe;
102pub mod option;
103pub mod reliability;
104pub mod uri;
105
106pub use blockwise::{BlockError, BlockOption, BlockReassembler, BlockValue};
107pub use bridge::{BridgeError, BridgeOp, CoapDdsBridge, map_method, parse_dds_path};
108pub use codec::{CodecError, decode, encode};
109pub use core_link::{CoreLink, decode_links, encode_links};
110pub use message::{CoapCode, CoapMessage, MessageType};
111pub use observe::{OBSERVE_OPTION_NUMBER, ObserveRegistry, ObserverEntry};
112pub use option::{CoapOption, OptionNumber, OptionValue};
113pub use reliability::{
114    ACK_TIMEOUT_MS, MAX_RETRANSMIT, PendingConfirmable, ReliabilityTracker, TickOutput,
115};