diff --git a/CHANGELOG.md b/CHANGELOG.md index d1ef349..23f2656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- `roslibrust::zenoh` now re-exports `open`, `Config`, and `Session`, allowing users to construct a + `ZenohClient` without depending directly on the `zenoh` crate. + ### Fixed - Zenoh clients no longer continuously subscribe to ROS 1 discovery beacons. Graph queries now diff --git a/Cargo.lock b/Cargo.lock index 3613645..f8f481f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3489,7 +3489,6 @@ dependencies = [ "test-log", "tokio", "tokio-stream", - "zenoh", ] [[package]] diff --git a/README.md b/README.md index 6a12acb..aaacc1e 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,11 @@ async fn main() -> Result<(), Box> { // Relay messages over a zenoh connection compatible with zenoh-ros1-plugin / zenoh-ros1-bridge #[cfg(feature = "zenoh")] { - let ros = roslibrust::zenoh::ZenohClient::new(zenoh::open(zenoh::Config::default()).await.unwrap()); + let ros = roslibrust::zenoh::ZenohClient::new( + roslibrust::zenoh::open(roslibrust::zenoh::Config::default()) + .await + .unwrap(), + ); relay(ros).await?; } diff --git a/roslibrust/Cargo.toml b/roslibrust/Cargo.toml index 34e4edf..bad63f1 100644 --- a/roslibrust/Cargo.toml +++ b/roslibrust/Cargo.toml @@ -34,8 +34,6 @@ roslibrust_codegen = { path = "../roslibrust_codegen" } roslibrust_codegen_macro = { path = "../roslibrust_codegen_macro" } # Slightly weird, but used in documentation examples roslibrust_test = { path = "../roslibrust_test" } -# Slightly weird, but used in documentation examples -zenoh = "1.7" # Provides test timeout ntest = "0.9" diff --git a/roslibrust_zenoh/src/lib.rs b/roslibrust_zenoh/src/lib.rs index 5f88b92..9eb3ca4 100644 --- a/roslibrust_zenoh/src/lib.rs +++ b/roslibrust_zenoh/src/lib.rs @@ -12,6 +12,10 @@ use std::{ }; use zenoh::bytes::ZBytes; +// Re-export the parts of Zenoh's session API needed to construct a `ZenohClient`, so users of +// `roslibrust::zenoh` do not also need a direct dependency on the `zenoh` crate. +pub use zenoh::{open, Config, Session}; + /// Serialize a runtime-selected message as the ROS1 message body carried by the Zenoh ROS1 /// bridge. pub fn serialize_dynamic_message(message: &DynamicMessage) -> DynamicMessageResult> { @@ -46,12 +50,12 @@ const DISCOVERY_COLLECTION_WINDOW: Duration = Duration::from_millis(2250); /// Should be created via [ZenohClient::new], and then used via the [TopicProvider] and [ServiceProvider] traits. #[derive(Clone)] pub struct ZenohClient { - session: zenoh::Session, + session: Session, } impl ZenohClient { /// Creates a new client wrapped around a Zenoh session - pub fn new(session: zenoh::Session) -> Self { + pub fn new(session: Session) -> Self { Self { session } } }