zerodds_zenoh_bridge/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 ZeroDDS Contributors
3
4//! Crate `zerodds-zenoh-bridge`. Safety classification: **STANDARD**.
5//!
6//! ZeroDDS ↔ Eclipse-Zenoh Bridge — `no_std + alloc` (pure-Rust
7//! Mapping-Layer ohne `zenoh`-Dep) plus Feature-gated `zenoh-runtime`
8//! fuer den voll-funktionalen Live-Bridge-Pfad.
9//!
10//! Verbindet einen ZeroDDS-DomainParticipant mit einer Zenoh-Session,
11//! sodass DDS-Topics auf Zenoh-Key-Expressions gemappt werden und in
12//! beide Richtungen gepumpt werden.
13//!
14//! # Architektur
15//!
16//! ```text
17//! DDS-Topic ────────► ZeroDDS DataReader
18//! │ │
19//! │ ▼ on_data
20//! │ Bridge::forward
21//! │ │
22//! │ ▼ zenoh::publisher::put
23//! │ Zenoh KeyExpr
24//! │ │
25//! │ ◄────────────────────┤ Zenoh Subscriber
26//! │ │
27//! │ Bridge::reverse
28//! │ │
29//! │ ▼ DataWriter::write
30//! ▼
31//! DDS-Topic
32//! ```
33//!
34//! # Feature-Gating
35//!
36//! - **default** — Skeleton-Crate ohne `zenoh`-Dep. Topic-Mapping-
37//! Logik + Tests laufen pure-Rust, sodass das Workspace-CI ohne
38//! externe Dependencies bleibt.
39//! - **zenoh-runtime** — bringt `zenoh = "1"` + `tokio`. Damit ist
40//! `ZenohBridge::start` voll funktional.
41//!
42//! # QoS-Mapping (DDS → Zenoh)
43//!
44//! | DDS-QoS | Zenoh-Aequivalent |
45//! |---------|-------------------|
46//! | `Reliability::Reliable` | `Reliability::Reliable` (Zenoh) |
47//! | `Reliability::BestEffort` | `Reliability::BestEffort` |
48//! | `Durability::TransientLocal` | `CongestionControl::Block` + `Priority::DataHigh` |
49//! | `Durability::Volatile` (Default) | `CongestionControl::Drop` |
50//! | `History::KeepLast(n)` | (Zenoh hat kein History-Cache; n>1 ignoriert) |
51//! | `Partition` | KeyExpr-Praefix (`<partition>/<topic>`) |
52//!
53//! # Spec-Referenz
54//!
55//! Es gibt keine OMG-Spec fuer Zenoh-Bridges. Diese Crate folgt dem
56//! De-facto-Pattern von ZettaScale's `zenoh-bridge-dds` (siehe
57//! <https://github.com/eclipse-zenoh/zenoh-plugin-dds>), aber als
58//! eigenstaendige Rust-Library statt Plugin.
59
60#![cfg_attr(not(feature = "std"), no_std)]
61#![warn(missing_docs)]
62#![forbid(unsafe_code)]
63
64extern crate alloc;
65
66mod mapping;
67
68pub use mapping::{TopicMap, dds_qos_to_zenoh, key_expr_for_topic};
69
70#[cfg(feature = "zenoh-runtime")]
71mod runtime;
72
73#[cfg(feature = "zenoh-runtime")]
74pub use runtime::{BridgeError, ZenohBridge, ZenohBridgeBuilder};