diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aeb3c0c..593e7b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: rustup component add rustfmt clippy - name: Code format check - run: cargo fmt --check + run: cargo fmt --check -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate" env: CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9b6d0d6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: local + hooks: + - id: fmt + name: fmt + entry: cargo fmt -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate" + language: system + types: [rust] diff --git a/Cargo.lock b/Cargo.lock index da09a2b..927279c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5071,7 +5071,7 @@ dependencies = [ [[package]] name = "zenoh" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "ahash", "async-trait", @@ -5142,7 +5142,7 @@ dependencies = [ [[package]] name = "zenoh-buffers" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "zenoh-collections", ] @@ -5150,7 +5150,7 @@ dependencies = [ [[package]] name = "zenoh-codec" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "serde", "tracing", @@ -5162,12 +5162,12 @@ dependencies = [ [[package]] name = "zenoh-collections" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" [[package]] name = "zenoh-config" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "flume", "json5", @@ -5189,7 +5189,7 @@ dependencies = [ [[package]] name = "zenoh-core" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-global-executor", "lazy_static", @@ -5201,7 +5201,7 @@ dependencies = [ [[package]] name = "zenoh-crypto" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "aes 0.8.3", "hmac 0.12.1", @@ -5214,7 +5214,7 @@ dependencies = [ [[package]] name = "zenoh-keyexpr" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "hashbrown 0.14.5", "keyed-set", @@ -5228,7 +5228,7 @@ dependencies = [ [[package]] name = "zenoh-link" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "zenoh-config", @@ -5246,7 +5246,7 @@ dependencies = [ [[package]] name = "zenoh-link-commons" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "flume", @@ -5270,7 +5270,7 @@ dependencies = [ [[package]] name = "zenoh-link-quic" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "base64 0.22.1", @@ -5301,7 +5301,7 @@ dependencies = [ [[package]] name = "zenoh-link-tcp" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "tokio", @@ -5319,7 +5319,7 @@ dependencies = [ [[package]] name = "zenoh-link-tls" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "base64 0.22.1", @@ -5349,7 +5349,7 @@ dependencies = [ [[package]] name = "zenoh-link-udp" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "socket2 0.5.6", @@ -5370,7 +5370,7 @@ dependencies = [ [[package]] name = "zenoh-link-unixsock_stream" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "futures 0.3.28", @@ -5390,7 +5390,7 @@ dependencies = [ [[package]] name = "zenoh-link-ws" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "futures-util", @@ -5411,7 +5411,7 @@ dependencies = [ [[package]] name = "zenoh-macros" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "proc-macro2", "quote", @@ -5422,7 +5422,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-rest" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "anyhow", "async-std", @@ -5477,7 +5477,7 @@ dependencies = [ [[package]] name = "zenoh-plugin-trait" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "libloading", "serde", @@ -5492,7 +5492,7 @@ dependencies = [ [[package]] name = "zenoh-protocol" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "const_format", "rand 0.8.5", @@ -5507,7 +5507,7 @@ dependencies = [ [[package]] name = "zenoh-result" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "anyhow", ] @@ -5515,7 +5515,7 @@ dependencies = [ [[package]] name = "zenoh-runtime" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "futures 0.3.28", "lazy_static", @@ -5530,7 +5530,7 @@ dependencies = [ [[package]] name = "zenoh-sync" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "event-listener 5.3.1", "futures 0.3.28", @@ -5544,7 +5544,7 @@ dependencies = [ [[package]] name = "zenoh-task" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "futures 0.3.28", "tokio", @@ -5557,7 +5557,7 @@ dependencies = [ [[package]] name = "zenoh-transport" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-trait", "flume", @@ -5589,7 +5589,7 @@ dependencies = [ [[package]] name = "zenoh-util" version = "0.11.0-dev" -source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#1790d59d1a9aa4995b3997f6fa96e90b24d28a25" +source = "git+https://github.com/eclipse-zenoh/zenoh.git?branch=dev/1.0.0#e021d0de69e589e06c4ec8f328097610ce52a44d" dependencies = [ "async-std", "async-trait", diff --git a/zenoh-bridge-ros1/src/main.rs b/zenoh-bridge-ros1/src/main.rs index f40bf02..ede2a9e 100644 --- a/zenoh-bridge-ros1/src/main.rs +++ b/zenoh-bridge-ros1/src/main.rs @@ -11,9 +11,10 @@ // Contributors: // ZettaScale Zenoh Team, // +use std::str::FromStr; + use async_std::channel::unbounded; use clap::{App, Arg}; -use std::str::FromStr; use zenoh::{ config::{Config, ZenohId}, internal::{plugins::PluginsManager, runtime::RuntimeBuilder}, diff --git a/zenoh-plugin-ros1/examples/ros1_standalone_sub.rs b/zenoh-plugin-ros1/examples/ros1_standalone_sub.rs index a7706b6..aa6e0d7 100644 --- a/zenoh-plugin-ros1/examples/ros1_standalone_sub.rs +++ b/zenoh-plugin-ros1/examples/ros1_standalone_sub.rs @@ -13,7 +13,6 @@ // use async_std::channel::unbounded; - use zenoh_plugin_ros1::ros_to_zenoh_bridge::environment::Environment; #[async_std::main] diff --git a/zenoh-plugin-ros1/examples/ros1_sub.rs b/zenoh-plugin-ros1/examples/ros1_sub.rs index 21f8e30..1ca81b4 100644 --- a/zenoh-plugin-ros1/examples/ros1_sub.rs +++ b/zenoh-plugin-ros1/examples/ros1_sub.rs @@ -60,7 +60,7 @@ async fn main() { print!("Creating Zenoh Publisher..."); let zenoh_publisher = zenoh_session .declare_publisher("some/ros/topic") - .congestion_control(zenoh::publisher::CongestionControl::Block) + .congestion_control(zenoh::qos::CongestionControl::Block) .await .unwrap(); println!(" OK!"); diff --git a/zenoh-plugin-ros1/src/lib.rs b/zenoh-plugin-ros1/src/lib.rs index aa304a9..4418e21 100644 --- a/zenoh-plugin-ros1/src/lib.rs +++ b/zenoh-plugin-ros1/src/lib.rs @@ -13,10 +13,11 @@ // #![recursion_limit = "1024"] -use ros_to_zenoh_bridge::environment::Environment; -use ros_to_zenoh_bridge::ros1_master_ctrl::Ros1MasterCtrl; -use ros_to_zenoh_bridge::Ros1ToZenohBridge; use std::time::Duration; + +use ros_to_zenoh_bridge::{ + environment::Environment, ros1_master_ctrl::Ros1MasterCtrl, Ros1ToZenohBridge, +}; use zenoh::{ internal::{ plugins::{RunningPlugin, RunningPluginTrait, ZenohPlugin}, diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge.rs index bf82f09..354d824 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge.rs @@ -12,16 +12,15 @@ // ZettaScale Zenoh Team, // -use async_std::task::JoinHandle; - -use tracing::error; -use zenoh::{self, core::Result as ZResult, Session}; - use std::sync::{ atomic::{AtomicBool, Ordering::Relaxed}, Arc, }; +use async_std::task::JoinHandle; +use tracing::error; +use zenoh::{self, Result as ZResult, Session}; + use self::{environment::Environment, ros1_to_zenoh_bridge_impl::work_cycle}; #[cfg(feature = "test")] diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/abstract_bridge.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/abstract_bridge.rs index 27d24f1..5531854 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/abstract_bridge.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/abstract_bridge.rs @@ -14,10 +14,9 @@ use std::sync::Arc; -use tracing::{debug, error, info}; - use rosrust::RawMessageDescription; -use zenoh::{core::Result as ZResult, internal::bail, key_expr::keyexpr, prelude::*}; +use tracing::{debug, error, info}; +use zenoh::{internal::bail, key_expr::keyexpr, prelude::*, Result as ZResult}; use super::{ bridge_type::BridgeType, ros1_client, topic_descriptor::TopicDescriptor, @@ -140,7 +139,7 @@ impl Ros1ToZenohClient { } struct Ros1ToZenohService { - _queryable: zenoh::queryable::Queryable<'static, ()>, + _queryable: zenoh::query::Queryable<'static, ()>, } impl Ros1ToZenohService { async fn new<'b>( @@ -297,7 +296,7 @@ impl Ros1ToZenoh { } struct ZenohToRos1 { - _subscriber: zenoh::subscriber::Subscriber<'static, ()>, + _subscriber: zenoh::pubsub::Subscriber<'static, ()>, } impl ZenohToRos1 { async fn new( diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_declaration.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_declaration.rs index 81eccb6..bb66826 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_declaration.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_declaration.rs @@ -12,14 +12,23 @@ // ZettaScale Zenoh Team, // -use zenoh::{ - core::Priority, internal::buffers::ZBuf, key_expr::OwnedKeyExpr, prelude::*, - publisher::CongestionControl, sample::Locality, subscriber::Reliability, Session, +use std::{ + sync::{ + atomic::{AtomicBool, AtomicUsize}, + Arc, + }, + time::Duration, }; -use std::sync::atomic::{AtomicBool, AtomicUsize}; -use std::sync::Arc; -use std::time::Duration; +use zenoh::{ + internal::buffers::ZBuf, + key_expr::OwnedKeyExpr, + prelude::*, + pubsub::Reliability, + qos::{CongestionControl, Priority}, + sample::Locality, + Session, +}; pub struct AlohaDeclaration { monitor_running: Arc, diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_subscription.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_subscription.rs index f9c3293..5945b4b 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_subscription.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/aloha_subscription.rs @@ -25,7 +25,7 @@ use async_std::sync::Mutex; use flume::Receiver; use futures::{join, Future, FutureExt}; use tracing::error; -use zenoh::{core::Result as ZResult, key_expr::OwnedKeyExpr, prelude::*, sample::Sample, Session}; +use zenoh::{key_expr::OwnedKeyExpr, prelude::*, sample::Sample, Result as ZResult, Session}; struct AlohaResource { activity: AtomicBool, @@ -134,7 +134,7 @@ impl AlohaSubscription { async fn listening_task<'a, F>( task_running: Arc, accumulating_resources: &Mutex>, - subscriber: &'a zenoh::subscriber::Subscriber<'a, Receiver>, + subscriber: &'a zenoh::pubsub::Subscriber<'a, Receiver>, on_resource_declared: &F, ) where F: Fn(zenoh::key_expr::KeyExpr) -> Box + Unpin + Send> diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/discovery.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/discovery.rs index 128a5c1..4d3e66e 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/discovery.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/discovery.rs @@ -12,9 +12,10 @@ // ZettaScale Zenoh Team, // +use std::{str, sync::Arc, time::Duration}; + use futures::Future; use tracing::error; - use zenoh::{ internal::bail, key_expr::{ @@ -23,16 +24,13 @@ use zenoh::{ }, }; -use std::str; -use std::sync::Arc; -use std::time::Duration; - -use super::aloha_declaration::AlohaDeclaration; -use super::aloha_subscription::{AlohaSubscription, AlohaSubscriptionBuilder}; -use super::bridge_type::BridgeType; -use super::topic_descriptor::TopicDescriptor; -use super::topic_utilities::{make_topic, make_topic_key}; - +use super::{ + aloha_declaration::AlohaDeclaration, + aloha_subscription::{AlohaSubscription, AlohaSubscriptionBuilder}, + bridge_type::BridgeType, + topic_descriptor::TopicDescriptor, + topic_utilities::{make_topic, make_topic_key}, +}; use crate::ZResult; kedefine!( diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/environment.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/environment.rs index 5b164f5..b5a9c80 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/environment.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/environment.rs @@ -12,12 +12,10 @@ // ZettaScale Zenoh Team, // +use std::{collections::HashMap, convert::From, marker::PhantomData, str::FromStr, time::Duration}; + use duration_string::DurationString; use rosrust::api::resolve::*; -use std::collections::HashMap; -use std::convert::From; -use std::time::Duration; -use std::{marker::PhantomData, str::FromStr}; use tracing::error; use super::bridging_mode::BridgingMode; diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/resource_cache.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/resource_cache.rs index 51f9014..b55d155 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/resource_cache.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/resource_cache.rs @@ -12,20 +12,20 @@ // ZettaScale Zenoh Team, // -use rosrust::{Publisher, RawMessage, RawMessageDescription}; use std::{ collections::{hash_map::Entry, HashMap}, net::{TcpStream, ToSocketAddrs}, sync::{Arc, Mutex}, time::Duration, }; + +use rosrust::{Publisher, RawMessage, RawMessageDescription, RosMsg}; use zenoh::{ - core::Result as ZResult, internal::{bail, zerror}, + Result as ZResult, }; use super::{ros1_client::Ros1Client, topic_descriptor::TopicDescriptor}; -use rosrust::RosMsg; pub type TopicName = String; pub type NodeName = String; diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_client.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_client.rs index af700a4..9aa7331 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_client.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_client.rs @@ -14,7 +14,7 @@ use rosrust::{self, RawMessageDescription}; use tracing::debug; -use zenoh::{core::Result as ZResult, internal::zerror}; +use zenoh::{internal::zerror, Result as ZResult}; use super::topic_descriptor::TopicDescriptor; diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_master_ctrl.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_master_ctrl.rs index 0b16bdd..45f8bff 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_master_ctrl.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_master_ctrl.rs @@ -19,8 +19,8 @@ use async_std::{ use atoi::atoi; use tracing::error; use zenoh::{ - core::Result as ZResult, internal::{bail, zasynclock, zerror}, + Result as ZResult, }; use crate::ros_to_zenoh_bridge::environment::Environment; diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_to_zenoh_bridge_impl.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_to_zenoh_bridge_impl.rs index 6d68ac8..c0e9bf8 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_to_zenoh_bridge_impl.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/ros1_to_zenoh_bridge_impl.rs @@ -12,6 +12,18 @@ // ZettaScale Zenoh Team, // +use std::{ + sync::{ + atomic::{AtomicBool, Ordering::Relaxed}, + Arc, + }, + time::Duration, +}; + +use async_std::sync::Mutex; +use tracing::{debug, error}; +use zenoh::{self, internal::zasynclock, Result as ZResult}; + use super::{ discovery::{RemoteResources, RemoteResourcesBuilder}, resource_cache::Ros1ResourceCache, @@ -21,16 +33,6 @@ use crate::ros_to_zenoh_bridge::{ bridges_storage::BridgesStorage, discovery::LocalResources, environment::Environment, ros1_client, topic_mapping, zenoh_client, }; -use async_std::sync::Mutex; -use std::{ - sync::{ - atomic::{AtomicBool, Ordering::Relaxed}, - Arc, - }, - time::Duration, -}; -use tracing::{debug, error}; -use zenoh::{self, core::Result as ZResult, internal::zasynclock}; #[derive(PartialEq, Clone, Copy)] pub enum RosStatus { diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/test_helpers.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/test_helpers.rs index 7475da3..81db0b0 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/test_helpers.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/test_helpers.rs @@ -12,35 +12,40 @@ // ZettaScale Zenoh Team, // +use std::{ + net::SocketAddr, + process::Command, + str::FromStr, + sync::{ + atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering::*}, + Arc, Mutex, RwLock, + }, + time::Duration, +}; + use async_std::prelude::FutureExt; use async_trait::async_trait; use futures::Future; use rosrust::{Client, RawMessage, RawMessageDescription}; -use std::process::Command; -use std::sync::atomic::AtomicBool; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering::*; -use std::sync::{Arc, Mutex, RwLock}; -use std::time::Duration; -use std::{net::SocketAddr, str::FromStr, sync::atomic::AtomicU16}; use tracing::error; use zenoh::{ config::ModeDependentValue, - core::Result as ZResult, internal::{bail, zlock}, key_expr::OwnedKeyExpr, prelude::*, sample::Sample, - session::SessionDeclarations, - Session, + Result as ZResult, Session, }; -use super::discovery::LocalResources; -use super::ros1_to_zenoh_bridge_impl::{work_cycle, BridgeStatus, RosStatus}; -use super::topic_descriptor::TopicDescriptor; -use super::topic_utilities; -use super::topic_utilities::make_topic_key; -use super::{ros1_client, zenoh_client}; +use super::{ + discovery::LocalResources, + ros1_client, + ros1_to_zenoh_bridge_impl::{work_cycle, BridgeStatus, RosStatus}, + topic_descriptor::TopicDescriptor, + topic_utilities, + topic_utilities::make_topic_key, + zenoh_client, +}; pub struct IsolatedPort { pub port: u16, @@ -320,7 +325,7 @@ impl BridgeChecker { &self, name: &str, callback: C, - ) -> zenoh::subscriber::Subscriber<'static, ()> + ) -> zenoh::pubsub::Subscriber<'static, ()> where C: Fn(Sample) + Send + Sync + 'static, { @@ -330,7 +335,7 @@ impl BridgeChecker { .unwrap() } - pub async fn make_zenoh_publisher(&self, name: &str) -> zenoh::publisher::Publisher<'static> { + pub async fn make_zenoh_publisher(&self, name: &str) -> zenoh::pubsub::Publisher<'static> { self.zenoh_client .publish(Self::make_zenoh_key(&Self::make_topic(name))) .await @@ -341,7 +346,7 @@ impl BridgeChecker { &self, name: &str, callback: Callback, - ) -> zenoh::queryable::Queryable<'static, ()> + ) -> zenoh::query::Queryable<'static, ()> where Callback: Fn(zenoh::query::Query) + Send + Sync + 'static, { @@ -514,7 +519,7 @@ impl TestParams { } pub struct ZenohPublisher { - pub inner: Arc>, + pub inner: Arc>, } pub struct ROS1Publisher { pub inner: Arc>>, @@ -731,10 +736,10 @@ impl Publisher for ROS1Client { } pub struct ZenohSubscriber { - pub _inner: zenoh::subscriber::Subscriber<'static, ()>, + pub _inner: zenoh::pubsub::Subscriber<'static, ()>, } pub struct ZenohQueryable { - pub _inner: zenoh::queryable::Queryable<'static, ()>, + pub _inner: zenoh::query::Queryable<'static, ()>, } pub struct ROS1Subscriber { pub inner: RAIICounter, diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_bridge.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_bridge.rs index 6d175da..1f04892 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_bridge.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_bridge.rs @@ -12,6 +12,10 @@ // ZettaScale Zenoh Team, // +use std::{fmt::Display, sync::Arc}; + +use tracing::error; + use super::{ abstract_bridge::AbstractBridge, bridge_type::BridgeType, @@ -21,8 +25,6 @@ use super::{ topic_descriptor::TopicDescriptor, zenoh_client, }; -use std::{fmt::Display, sync::Arc}; -use tracing::error; pub struct TopicBridge { topic: TopicDescriptor, diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_mapping.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_mapping.rs index c58acdf..0776d5a 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_mapping.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/topic_mapping.rs @@ -14,9 +14,8 @@ use std::collections::HashSet; -use crate::ros_to_zenoh_bridge::ros1_client; - use super::{resource_cache::Ros1ResourceCache, topic_descriptor::TopicDescriptor}; +use crate::ros_to_zenoh_bridge::ros1_client; #[derive(Debug)] pub struct Ros1TopicMapping { diff --git a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/zenoh_client.rs b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/zenoh_client.rs index 128943e..1dcd0cf 100644 --- a/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/zenoh_client.rs +++ b/zenoh-plugin-ros1/src/ros_to_zenoh_bridge/zenoh_client.rs @@ -12,20 +12,17 @@ // ZettaScale Zenoh Team, // -use std::fmt::Display; -use std::sync::Arc; +use std::{fmt::Display, sync::Arc}; use tracing::debug; - use zenoh::{ - core::Result as ZResult, key_expr::KeyExpr, prelude::*, - publisher::CongestionControl, + pubsub::Reliability, + qos::CongestionControl, + query::Selector, sample::{Locality, Sample}, - selector::Selector, - subscriber::Reliability, - Session, + Result as ZResult, Session, }; pub struct ZenohClient { @@ -42,7 +39,7 @@ impl ZenohClient { &self, key_expr: TryIntoKeyExpr, callback: C, - ) -> ZResult> + ) -> ZResult> where C: Fn(Sample) + Send + Sync + 'static, TryIntoKeyExpr: TryInto> + Display, @@ -61,7 +58,7 @@ impl ZenohClient { pub async fn publish<'b: 'static, TryIntoKeyExpr>( &self, key_expr: TryIntoKeyExpr, - ) -> ZResult> + ) -> ZResult> where TryIntoKeyExpr: TryInto> + Display, >>::Error: Into, @@ -79,7 +76,7 @@ impl ZenohClient { &self, key_expr: TryIntoKeyExpr, callback: Callback, - ) -> ZResult> + ) -> ZResult> where Callback: Fn(zenoh::query::Query) + Send + Sync + 'static, TryIntoKeyExpr: TryInto> + Display, diff --git a/zenoh-plugin-ros1/tests/aloha_declaration_test.rs b/zenoh-plugin-ros1/tests/aloha_declaration_test.rs index f35a688..cac6202 100644 --- a/zenoh-plugin-ros1/tests/aloha_declaration_test.rs +++ b/zenoh-plugin-ros1/tests/aloha_declaration_test.rs @@ -12,16 +12,15 @@ // ZettaScale Zenoh Team, // -use async_std::{prelude::FutureExt, sync::Mutex}; use std::{ collections::HashSet, str::FromStr, sync::{atomic::AtomicUsize, Arc}, time::Duration, }; -use zenoh::{ - core::Result as ZResult, key_expr::OwnedKeyExpr, prelude::*, session::OpenBuilder, Session, -}; + +use async_std::{prelude::FutureExt, sync::Mutex}; +use zenoh::{key_expr::OwnedKeyExpr, prelude::*, session::OpenBuilder, Result as ZResult, Session}; use zenoh_plugin_ros1::ros_to_zenoh_bridge::{ aloha_declaration, aloha_subscription, test_helpers::IsolatedConfig, }; @@ -90,7 +89,7 @@ fn aloha_instantination_many_instances() { } pub struct PPCMeasurement<'a> { - _subscriber: zenoh::subscriber::Subscriber<'a, ()>, + _subscriber: zenoh::pubsub::Subscriber<'a, ()>, ppc: Arc, measurement_period: Duration, } diff --git a/zenoh-plugin-ros1/tests/bridge_to_bridge.rs b/zenoh-plugin-ros1/tests/bridge_to_bridge.rs index c5a3613..1adfa0f 100644 --- a/zenoh-plugin-ros1/tests/bridge_to_bridge.rs +++ b/zenoh-plugin-ros1/tests/bridge_to_bridge.rs @@ -12,23 +12,26 @@ // ZettaScale Zenoh Team, // +use std::{ + collections::HashSet, + sync::{ + atomic::{AtomicU64, AtomicUsize, Ordering::*}, + Arc, + }, + time::Duration, +}; + use async_std::prelude::FutureExt; use rosrust::RawMessage; -use std::sync::atomic::{AtomicUsize, Ordering::*}; -use std::sync::Arc; -use std::time::Duration; -use std::{collections::HashSet, sync::atomic::AtomicU64}; use strum_macros::Display; use tracing::{debug, trace}; use zenoh::key_expr::{KeyExpr, OwnedKeyExpr}; -use zenoh_plugin_ros1::ros_to_zenoh_bridge::test_helpers::{ - self, wait_async, Publisher, Subscriber, -}; use zenoh_plugin_ros1::ros_to_zenoh_bridge::{ bridging_mode::BridgingMode, environment::Environment, test_helpers::{ - BridgeChecker, IsolatedConfig, IsolatedROSMaster, ROSEnvironment, RunningBridge, TestParams, + self, wait_async, BridgeChecker, IsolatedConfig, IsolatedROSMaster, Publisher, + ROSEnvironment, RunningBridge, Subscriber, TestParams, }, }; diff --git a/zenoh-plugin-ros1/tests/discovery_test.rs b/zenoh-plugin-ros1/tests/discovery_test.rs index 292db15..90e58cc 100644 --- a/zenoh-plugin-ros1/tests/discovery_test.rs +++ b/zenoh-plugin-ros1/tests/discovery_test.rs @@ -12,12 +12,13 @@ // ZettaScale Zenoh Team, // -use async_std::prelude::FutureExt; -use multiset::HashMultiSet; use std::{ sync::{Arc, Mutex}, time::Duration, }; + +use async_std::prelude::FutureExt; +use multiset::HashMultiSet; use zenoh::{key_expr::keyexpr, prelude::*, session::OpenBuilder, Session}; use zenoh_plugin_ros1::ros_to_zenoh_bridge::{ discovery::{self, LocalResources, RemoteResources}, diff --git a/zenoh-plugin-ros1/tests/ping_pong_test.rs b/zenoh-plugin-ros1/tests/ping_pong_test.rs index aff4f2c..708fe78 100644 --- a/zenoh-plugin-ros1/tests/ping_pong_test.rs +++ b/zenoh-plugin-ros1/tests/ping_pong_test.rs @@ -12,33 +12,30 @@ // ZettaScale Zenoh Team, // -use async_std::prelude::FutureExt; -use std::sync::atomic::AtomicUsize; use std::{ collections::HashSet, sync::{ - atomic::{AtomicBool, AtomicU64, Ordering::*}, + atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering::*}, Arc, }, + thread, time, time::Duration, }; -use std::{thread, time}; + +use async_std::prelude::FutureExt; use strum_macros::Display; use tracing::{debug, trace}; use zenoh::{key_expr::KeyExpr, prelude::*}; use zenoh_plugin_ros1::ros_to_zenoh_bridge::{ bridging_mode::BridgingMode, + discovery::LocalResource, environment::Environment, test_helpers::{ - self, wait_async_fn, BridgeChecker, Publisher, ROS1Client, ROS1Publisher, ROS1Service, - ROS1Subscriber, ROSEnvironment, RunningBridge, Subscriber, TestParams, ZenohPublisher, - ZenohQuery, ZenohQueryable, ZenohSubscriber, + self, wait_async_fn, BridgeChecker, IsolatedConfig, IsolatedROSMaster, Publisher, + ROS1Client, ROS1Publisher, ROS1Service, ROS1Subscriber, ROSEnvironment, RunningBridge, + Subscriber, TestParams, ZenohPublisher, ZenohQuery, ZenohQueryable, ZenohSubscriber, }, }; -use zenoh_plugin_ros1::ros_to_zenoh_bridge::{ - discovery::LocalResource, - test_helpers::{IsolatedConfig, IsolatedROSMaster}, -}; #[test] fn env_checks_no_master_init_and_exit_immed() {