From 63346f0bd59c218e13ee4d9444e1c0403fc68e56 Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Mon, 16 Oct 2023 12:46:43 +0200 Subject: [PATCH] concat_enabled_features --- plugins/zenoh-plugin-trait/src/lib.rs | 15 +++++++++------ zenoh/src/net/runtime/mod.rs | 8 +++++--- zenoh/src/plugins/sealed.rs | 23 ++++++++++++++++++++++- zenohd/src/main.rs | 1 - 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/plugins/zenoh-plugin-trait/src/lib.rs b/plugins/zenoh-plugin-trait/src/lib.rs index c21655e5c4..d6b4475bcb 100644 --- a/plugins/zenoh-plugin-trait/src/lib.rs +++ b/plugins/zenoh-plugin-trait/src/lib.rs @@ -24,15 +24,18 @@ pub mod vtable; use zenoh_result::ZResult; pub mod prelude { - pub use crate::{loading::*, vtable::*, Plugin, CompatibilityVersion}; + pub use crate::{loading::*, vtable::*, CompatibilityVersion, Plugin}; } #[macro_export] -macro_rules! version_with_features { - ($version:literal, $($feature:literal),*) => { - concatcp!($version $(, - if cfg!(feature = $feature) { concatcp!(" ", $feature) } else { "" } - )*) +macro_rules! concat_enabled_features { + ($version:ident, $($feature:literal),*) => { + { + use const_format::concatcp; + const_format::concatcp!($version $(, + if cfg!(feature = $feature) { concatcp!(" ", $feature) } else { "" } + )*) + } }; } pub trait CompatibilityVersion { diff --git a/zenoh/src/net/runtime/mod.rs b/zenoh/src/net/runtime/mod.rs index 509aac0dac..f3ca4a78db 100644 --- a/zenoh/src/net/runtime/mod.rs +++ b/zenoh/src/net/runtime/mod.rs @@ -38,7 +38,7 @@ use stop_token::future::FutureExt; use stop_token::{StopSource, TimedOutError}; use uhlc::{HLCBuilder, HLC}; use zenoh_link::{EndPoint, Link}; -use zenoh_plugin_trait::{CompatibilityVersion, version_with_features}; +use zenoh_plugin_trait::{CompatibilityVersion, concat_enabled_features}; use zenoh_protocol::core::{whatami::WhatAmIMatcher, Locator, WhatAmI, ZenohId}; use zenoh_protocol::network::{NetworkBody, NetworkMessage}; use zenoh_result::{bail, ZResult}; @@ -66,10 +66,12 @@ pub struct Runtime { state: Arc, } +const RUNTIME_VERSION: &str = "1"; + impl CompatibilityVersion for Runtime { fn version() -> &'static str { - version_with_features!( - "1", + concat_enabled_features!( + RUNTIME_VERSION, "auth_pubkey", "auth_usrpwd", "complete_n", diff --git a/zenoh/src/plugins/sealed.rs b/zenoh/src/plugins/sealed.rs index da75ea6711..5b2d48374b 100644 --- a/zenoh/src/plugins/sealed.rs +++ b/zenoh/src/plugins/sealed.rs @@ -31,9 +31,29 @@ pub type StartArgs = Runtime; /// A zenoh plugin, when started, must return this type. pub type RunningPlugin = Box; +const RUNNING_PLUGIN_VERSION: &str = "1"; + impl CompatibilityVersion for RunningPlugin { fn version() -> &'static str { - "1" + concat_enabled_features!( + RUNNING_PLUGIN_VERSION, + "auth_pubkey", + "auth_usrpwd", + "complete_n", + "shared-memory", + "stats", + "transport_multilink", + "transport_quic", + "transport_serial", + "transport_unixpipe", + "transport_tcp", + "transport_tls", + "transport_udp", + "transport_unixsock-stream", + "transport_ws", + "unstable", + "default" + ) } } @@ -81,5 +101,6 @@ pub trait RunningPluginTrait: Send + Sync { /// The zenoh plugins manager. It handles the full lifetime of plugins, from loading to destruction. pub type PluginsManager = zenoh_plugin_trait::loading::PluginsManager; +use zenoh_plugin_trait::concat_enabled_features; pub use zenoh_plugin_trait::CompatibilityVersion; pub use zenoh_plugin_trait::Plugin; diff --git a/zenohd/src/main.rs b/zenohd/src/main.rs index 820e29d9c1..28df513a46 100644 --- a/zenohd/src/main.rs +++ b/zenohd/src/main.rs @@ -20,7 +20,6 @@ use zenoh::config::{Config, ModeDependentValue, PermissionsConf, PluginLoad, Val use zenoh::plugins::PluginsManager; use zenoh::prelude::{EndPoint, WhatAmI}; use zenoh::runtime::{AdminSpace, Runtime}; -use zenoh::plugins::CompatibilityVersion; const GIT_VERSION: &str = git_version!(prefix = "v", cargo_prefix = "v");