hiroz_protocol/lib.rs
1//! Key expression format handling for hiroz.
2//!
3//! This crate provides key expression generation for mapping ROS 2 entities
4//! (nodes, topics, services, actions) to Zenoh key expressions.
5//!
6//! # Formats
7//!
8//! hiroz supports multiple key expression formats:
9//!
10//! - **RmwZenoh** (default): Compatible with `rmw_zenoh_cpp`, the official
11//! ROS 2 RMW implementation using Zenoh. Uses `strip_slashes()` for topic
12//! key expressions and mangling for liveliness tokens.
13//!
14//! - **Ros2Dds**: Compatible with `zenoh-plugin-ros2dds`, useful for bridging
15//! between Zenoh and DDS networks.
16//!
17//! # no_std Support
18//!
19//! This crate is `no_std` compatible with `alloc`:
20//!
21//! ```toml
22//! [dependencies]
23//! hiroz-protocol = { version = "0.1", default-features = false }
24//! ```
25//!
26//! # Example
27//!
28//! ```rust
29//! use hiroz_protocol::{KeyExprFormat, entity::*};
30//!
31//! let format = KeyExprFormat::default(); // RmwZenoh
32//! let zid: zenoh::session::ZenohId = "1234567890abcdef1234567890abcdef".parse().unwrap();
33//! let node = NodeEntity::new(0, zid, 0, "my_node".to_string(), "/".to_string(), String::new());
34//!
35//! let entity = EndpointEntity {
36//! id: 1,
37//! node: Some(node),
38//! kind: EndpointKind::Publisher,
39//! topic: "/chatter".to_string(),
40//! type_info: None,
41//! qos: Default::default(),
42//! };
43//!
44//! // Generate topic key expression
45//! let topic_ke = format.topic_key_expr(&entity).unwrap();
46//! ```
47
48#![cfg_attr(not(feature = "std"), no_std)]
49
50extern crate alloc;
51
52pub mod entity;
53pub mod format;
54pub mod qos;
55
56pub use entity::{
57 EndpointEntity, EndpointKind, Entity, EntityKind, NodeEntity, TypeHash, TypeInfo,
58};
59#[cfg(feature = "rmw-zenoh")]
60pub use format::rmw_zenoh::RmwZenohFormatter;
61#[cfg(feature = "ros2dds")]
62pub use format::ros2dds::Ros2DdsFormatter;
63pub use format::{KeyExprFormat, KeyExprFormatter};