From ec60161c5f55c8adb0e962617aa05ed873419a0e Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Tue, 14 Oct 2025 18:56:13 +0200 Subject: [PATCH 01/30] [#865] Add minimal Once implementation using iceoryx2 concurrency primitives --- iceoryx2-pal/concurrency-sync/src/lib.rs | 1 + iceoryx2-pal/concurrency-sync/src/once.rs | 120 ++++++++++++++++++ .../concurrency-sync/tests/once_tests.rs | 68 ++++++++++ 3 files changed, 189 insertions(+) create mode 100644 iceoryx2-pal/concurrency-sync/src/once.rs create mode 100644 iceoryx2-pal/concurrency-sync/tests/once_tests.rs diff --git a/iceoryx2-pal/concurrency-sync/src/lib.rs b/iceoryx2-pal/concurrency-sync/src/lib.rs index a0c8e9968..768b6495c 100644 --- a/iceoryx2-pal/concurrency-sync/src/lib.rs +++ b/iceoryx2-pal/concurrency-sync/src/lib.rs @@ -18,6 +18,7 @@ pub mod barrier; pub mod condition_variable; pub mod iox_atomic; pub mod mutex; +pub mod once; pub mod rwlock; pub mod semaphore; diff --git a/iceoryx2-pal/concurrency-sync/src/once.rs b/iceoryx2-pal/concurrency-sync/src/once.rs new file mode 100644 index 000000000..69b21af2b --- /dev/null +++ b/iceoryx2-pal/concurrency-sync/src/once.rs @@ -0,0 +1,120 @@ +// Copyright (c) 2025 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache Software License 2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license +// which is available at https://opensource.org/licenses/MIT. +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +use crate::iox_atomic::IoxAtomicU8; +use core::sync::atomic::Ordering; + +#[repr(u8)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum State { + Incomplete = 0, + InProgress = 1, + Complete = 2, +} + +impl From for State { + fn from(value: u8) -> Self { + match value { + 0 => State::Incomplete, + 1 => State::InProgress, + 2 => State::Complete, + _ => unreachable!("Invalid state"), + } + } +} + +/// A spin-based one-time initialization primitive. +/// +/// This provides similar functionality to `std::sync::Once` but uses only +/// spin-waiting instead of OS-level blocking primitives. +/// +/// # Examples +/// +/// ``` +/// use iceoryx2_pal_concurrency_sync::once::Once; +/// +/// static INIT: Once = Once::new(); +/// +/// fn initialize() { +/// INIT.call_once(|| { +/// // This will only run once, even if called from multiple threads +/// println!("Initializing..."); +/// }); +/// } +/// ``` +pub struct Once { + state: IoxAtomicU8, +} + +impl Default for Once { + fn default() -> Self { + Self::new() + } +} + +impl Once { + /// Creates a new `Once` in the uninitialized state. + pub const fn new() -> Self { + Self { + state: IoxAtomicU8::new(State::Incomplete as u8), + } + } + + /// Executes the given closure if this is the first call to `call_once`. + /// + /// If multiple threads call this simultaneously, only one will execute + /// the closure. Other threads will spin-wait until initialization completes. + /// + /// # Panics + /// + /// If the closure `f` panics, the panic will propagate and the `Once` + /// will be left in an inconsistent state. + pub fn call_once(&self, f: F) { + if self.load_state() == State::Complete { + return; + } + + if self.try_start_init() { + f(); + self.state.store(State::Complete as u8, Ordering::Release); + } else { + while self.load_state() != State::Complete { + core::hint::spin_loop(); + } + } + } + + /// Returns `true` if the initialization has been completed. + /// + /// This method can be used to check whether the closure passed to + /// `call_once` has already been executed without re-triggering initialization. + pub fn is_completed(&self) -> bool { + self.load_state() == State::Complete + } + + #[inline] + fn load_state(&self) -> State { + self.state.load(Ordering::Acquire).into() + } + + #[inline] + fn try_start_init(&self) -> bool { + self.state + .compare_exchange( + State::Incomplete as u8, + State::InProgress as u8, + Ordering::Acquire, + Ordering::Relaxed, + ) + .is_ok() + } +} diff --git a/iceoryx2-pal/concurrency-sync/tests/once_tests.rs b/iceoryx2-pal/concurrency-sync/tests/once_tests.rs new file mode 100644 index 000000000..a6d6761b2 --- /dev/null +++ b/iceoryx2-pal/concurrency-sync/tests/once_tests.rs @@ -0,0 +1,68 @@ +// Copyright (c) 2025 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache Software License 2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license +// which is available at https://opensource.org/licenses/MIT. +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +use core::sync::atomic::{AtomicU32, Ordering}; + +use iceoryx2_pal_concurrency_sync::{barrier::Barrier, once::Once}; +use iceoryx2_pal_testing::assert_that; + +#[test] +fn once_executes_exactly_once() { + let once = Once::new(); + let counter = AtomicU32::new(0); + + once.call_once(|| { + counter.fetch_add(1, Ordering::Relaxed); + }); + + once.call_once(|| { + counter.fetch_add(1, Ordering::Relaxed); + }); + + once.call_once(|| { + counter.fetch_add(1, Ordering::Relaxed); + }); + + assert_that!(counter.load(Ordering::Relaxed), eq 1); + assert_that!(once.is_completed(), eq true); +} + +#[test] +fn once_works_with_multiple_threads() { + const NUMBER_OF_THREADS: u32 = 10; + + let once = Once::new(); + let barrier = Barrier::new(NUMBER_OF_THREADS + 1); + let counter = AtomicU32::new(0); + + std::thread::scope(|s| { + for _ in 0..NUMBER_OF_THREADS { + s.spawn(|| { + barrier.wait(|_, _| {}, |_| {}); + once.call_once(|| { + counter.fetch_add(1, Ordering::Relaxed); + }); + }); + } + + barrier.wait(|_, _| {}, |_| {}); + }); + + assert_that!(counter.load(Ordering::Relaxed), eq 1); + assert_that!(once.is_completed(), eq true); +} + +#[test] +fn once_is_completed_returns_false_initially() { + let once = Once::new(); + assert_that!(once.is_completed(), eq false); +} From f4464332ffbd93a8fdb31e4f78e0ffb2da91ec68 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Tue, 14 Oct 2025 18:03:06 +0200 Subject: [PATCH 02/30] [#865] Add null logger --- iceoryx2-bb/log/Cargo.toml | 6 ++ iceoryx2-bb/log/src/lib.rs | 122 +++++++++++++++++++---------- iceoryx2-bb/log/src/log.rs | 42 +++++----- iceoryx2-bb/log/src/logger/mod.rs | 7 ++ iceoryx2-bb/log/src/logger/null.rs | 38 +++++++++ iceoryx2/Cargo.toml | 6 ++ 6 files changed, 158 insertions(+), 63 deletions(-) create mode 100644 iceoryx2-bb/log/src/logger/null.rs diff --git a/iceoryx2-bb/log/Cargo.toml b/iceoryx2-bb/log/Cargo.toml index 9d517b391..2a6d6e255 100644 --- a/iceoryx2-bb/log/Cargo.toml +++ b/iceoryx2-bb/log/Cargo.toml @@ -11,6 +11,12 @@ rust-version = { workspace = true } version = { workspace = true } [features] +default = ["std"] +std = [] + +logger_buffer = [] +logger_file = [] +logger_console = [] # Enables https://crates.io/crates/log as default logger logger_log = ["dep:log"] # Enables https://crates.io/crates/tracing as default logger diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index b85a4056e..11c0d1aaa 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -10,6 +10,7 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +#![cfg_attr(not(any(test, feature = "std")), no_std)] #![warn(clippy::alloc_instead_of_core)] #![warn(clippy::std_instead_of_alloc)] #![warn(clippy::std_instead_of_core)] @@ -142,6 +143,21 @@ //! } //! ``` +#[cfg(all(feature = "logger_buffer", not(feature = "std")))] +compile_error!("The 'logger_buffer' feature requires the 'std' feature to be enabled"); + +#[cfg(all(feature = "logger_file", not(feature = "std")))] +compile_error!("The 'logger_file' feature requires the 'std' feature to be enabled"); + +#[cfg(all(feature = "logger_console", not(feature = "std")))] +compile_error!("The 'logger_console' feature requires the 'std' feature to be enabled"); + +#[cfg(all(feature = "logger_log", not(feature = "std")))] +compile_error!("The 'logger_log' feature requires the 'std' feature to be enabled"); + +#[cfg(all(feature = "logger_tracing", not(feature = "std")))] +compile_error!("The 'logger_tracing' feature requires the 'std' feature to be enabled"); + extern crate alloc; #[macro_use] @@ -150,12 +166,12 @@ pub mod log; pub mod fail; pub mod logger; -use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU8; +#[cfg(feature = "std")] +pub use from_env::{set_log_level_from_env_or, set_log_level_from_env_or_default}; -use core::{fmt::Arguments, sync::atomic::Ordering}; -use std::sync::Once; +use iceoryx2_pal_concurrency_sync::{iox_atomic::IoxAtomicU8, once::Once}; -use std::env; +use core::{fmt::Arguments, sync::atomic::Ordering}; #[cfg(feature = "logger_tracing")] static DEFAULT_LOGGER: logger::tracing::Logger = logger::tracing::Logger::new(); @@ -163,9 +179,24 @@ static DEFAULT_LOGGER: logger::tracing::Logger = logger::tracing::Logger::new(); #[cfg(feature = "logger_log")] static DEFAULT_LOGGER: logger::log::Logger = logger::log::Logger::new(); -#[cfg(not(any(feature = "logger_log", feature = "logger_tracing")))] +#[cfg(feature = "logger_file")] +static DEFAULT_LOGGER: logger::file::Logger = logger::file::Logger::new(); + +#[cfg(feature = "logger_buffer")] +static DEFAULT_LOGGER: logger::buffer::Logger = logger::buffer::Logger::new(); + +#[cfg(feature = "logger_console")] static DEFAULT_LOGGER: logger::console::Logger = logger::console::Logger::new(); +#[cfg(not(any( + feature = "logger_tracing", + feature = "logger_log", + feature = "logger_file", + feature = "logger_buffer", + feature = "logger_console" +)))] +static DEFAULT_LOGGER: logger::null::Logger = logger::null::Logger::new(); + const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Info; static mut LOGGER: Option<&'static dyn Log> = None; @@ -189,43 +220,6 @@ pub enum LogLevel { Fatal = 5, } -impl LogLevel { - fn from_str_fuzzy(log_level_string: &str, log_level_fallback: LogLevel) -> LogLevel { - match log_level_string.to_lowercase().as_str() { - "trace" => LogLevel::Trace, - "debug" => LogLevel::Debug, - "info" => LogLevel::Info, - "warn" => LogLevel::Warn, - "error" => LogLevel::Error, - "fatal" => LogLevel::Fatal, - _ => { - eprintln!( - "Invalid value for 'IOX2_LOG_LEVEL' environment variable!\ - \nFound: {log_level_string:?}\ - \nAllowed is one of: fatal, error, warn, info, debug, trace\ - \nSetting log level as : {log_level_fallback:?}" - ); - log_level_fallback - } - } - } -} - -/// Sets the log level by reading environment variable "IOX2_LOG_LEVEL" or default it with LogLevel::INFO -pub fn set_log_level_from_env_or_default() { - set_log_level_from_env_or(DEFAULT_LOG_LEVEL); -} - -/// Sets the log level by reading environment variable "IOX2_LOG_LEVEL", and if the environment variable -/// doesn't exit it sets it with a user-defined logging level -pub fn set_log_level_from_env_or(v: LogLevel) { - let log_level = env::var("IOX2_LOG_LEVEL") - .ok() - .map(|s| LogLevel::from_str_fuzzy(&s, v)) - .unwrap_or(v); - set_log_level(log_level); -} - /// Sets the current log level. This is ignored for external frameworks like `log` or `tracing`. /// Here you have to use the log-level settings of that framework. pub fn set_log_level(v: LogLevel) { @@ -271,6 +265,50 @@ pub fn get_logger() -> &'static dyn Log { } } +#[cfg(feature = "std")] +mod from_env { + use super::{set_log_level, LogLevel, DEFAULT_LOG_LEVEL}; + use std::env; + + fn get_log_level_from_str_fuzzy( + log_level_string: &str, + log_level_fallback: LogLevel, + ) -> LogLevel { + match log_level_string.to_lowercase().as_str() { + "trace" => LogLevel::Trace, + "debug" => LogLevel::Debug, + "info" => LogLevel::Info, + "warn" => LogLevel::Warn, + "error" => LogLevel::Error, + "fatal" => LogLevel::Fatal, + _ => { + eprintln!( + "Invalid value for 'IOX2_LOG_LEVEL' environment variable!\ + \nFound: {log_level_string:?}\ + \nAllowed is one of: fatal, error, warn, info, debug, trace\ + \nSetting log level as : {log_level_fallback:?}" + ); + log_level_fallback + } + } + } + + /// Sets the log level by reading environment variable "IOX2_LOG_LEVEL" or default it with LogLevel::INFO + pub fn set_log_level_from_env_or_default() { + set_log_level_from_env_or(DEFAULT_LOG_LEVEL); + } + + /// Sets the log level by reading environment variable "IOX2_LOG_LEVEL", and if the environment variable + /// doesn't exit it sets it with a user-defined logging level + pub fn set_log_level_from_env_or(v: LogLevel) { + let log_level = env::var("IOX2_LOG_LEVEL") + .ok() + .map(|s| get_log_level_from_str_fuzzy(&s, v)) + .unwrap_or(v); + set_log_level(log_level); + } +} + #[doc(hidden)] pub fn __internal_print_log_msg(log_level: LogLevel, origin: Arguments, args: Arguments) { if get_log_level() <= log_level as u8 { diff --git a/iceoryx2-bb/log/src/log.rs b/iceoryx2-bb/log/src/log.rs index 1f2d4b325..3c1597293 100644 --- a/iceoryx2-bb/log/src/log.rs +++ b/iceoryx2-bb/log/src/log.rs @@ -38,16 +38,16 @@ #[macro_export(local_inner_macros)] macro_rules! trace { ($($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Trace, std::format_args!(""), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Trace, core::format_args!(""), core::format_args!($($e),*)) }; (from $o:expr, $($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Trace, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Trace, core::format_args!("{:?}", $o), core::format_args!($($e),*)) }; (from $o:expr, when $call:expr, $($e:expr),*) => { { let result = $call; if result.is_err() { - $crate::__internal_print_log_msg($crate::LogLevel::Trace, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Trace, core::format_args!("{:?}", $o), core::format_args!($($e),*)) } } } @@ -79,16 +79,16 @@ macro_rules! trace { #[macro_export(local_inner_macros)] macro_rules! debug { ($($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Debug, std::format_args!(""), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Debug, core::format_args!(""), core::format_args!($($e),*)) }; (from $o:expr, $($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Debug, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Debug, core::format_args!("{:?}", $o), core::format_args!($($e),*)) }; (from $o:expr, when $call:expr, $($e:expr),*) => { { let result = $call; if result.is_err() { - $crate::__internal_print_log_msg($crate::LogLevel::Debug, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Debug, core::format_args!("{:?}", $o), core::format_args!($($e),*)) } } } @@ -120,16 +120,16 @@ macro_rules! debug { #[macro_export(local_inner_macros)] macro_rules! info { ($($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Info, std::format_args!(""), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Info, core::format_args!(""), core::format_args!($($e),*)) }; (from $o:expr, $($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Info, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Info, core::format_args!("{:?}", $o), core::format_args!($($e),*)) }; (from $o:expr, when $call:expr, $($e:expr),*) => { { let result = $call; if result.is_err() { - $crate::__internal_print_log_msg($crate::LogLevel::Info, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Info, core::format_args!("{:?}", $o), core::format_args!($($e),*)) } } } @@ -161,16 +161,16 @@ macro_rules! info { #[macro_export(local_inner_macros)] macro_rules! warn { ($($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Warn, std::format_args!(""), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Warn, core::format_args!(""), core::format_args!($($e),*)) }; (from $o:expr, $($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Warn, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Warn, core::format_args!("{:?}", $o), core::format_args!($($e),*)) }; (from $o:expr, when $call:expr, $($e:expr),*) => { { let result = $call; if result.is_err() { - $crate::__internal_print_log_msg($crate::LogLevel::Warn, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Warn, core::format_args!("{:?}", $o), core::format_args!($($e),*)) } } } @@ -202,16 +202,16 @@ macro_rules! warn { #[macro_export(local_inner_macros)] macro_rules! error { ($($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Error, std::format_args!(""), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Error, core::format_args!(""), core::format_args!($($e),*)) }; (from $o:expr, $($e:expr),*) => { - $crate::__internal_print_log_msg($crate::LogLevel::Error, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Error, core::format_args!("{:?}", $o), core::format_args!($($e),*)) }; (from $o:expr, when $call:expr, $($e:expr),*) => { { let result = $call; if result.is_err() { - $crate::__internal_print_log_msg($crate::LogLevel::Error, std::format_args!("{:?}", $o), std::format_args!($($e),*)) + $crate::__internal_print_log_msg($crate::LogLevel::Error, core::format_args!("{:?}", $o), core::format_args!($($e),*)) } } } @@ -244,22 +244,22 @@ macro_rules! error { macro_rules! fatal_panic { ($($e:expr),*) => { { - $crate::__internal_print_log_msg($crate::LogLevel::Fatal, std::format_args!(""), std::format_args!($($e),*)); - std::panic!($($e),*); + $crate::__internal_print_log_msg($crate::LogLevel::Fatal, core::format_args!(""), core::format_args!($($e),*)); + core::panic!($($e),*); } }; (from $o:expr, $($e:expr),*) => { { - $crate::__internal_print_log_msg($crate::LogLevel::Fatal, std::format_args!("{:?}", $o), std::format_args!($($e),*)); - std::panic!("From: {:?} ::: {}", $o, std::format_args!($($e),*)); + $crate::__internal_print_log_msg($crate::LogLevel::Fatal, core::format_args!("{:?}", $o), core::format_args!($($e),*)); + core::panic!("From: {:?} ::: {}", $o, core::format_args!($($e),*)); } }; (from $o:expr, when $call:expr, $($e:expr),*) => { { let result = $call; if result.is_err() { - $crate::__internal_print_log_msg($crate::LogLevel::Fatal, std::format_args!("{:?}", $o), std::format_args!($($e),*)); - std::panic!("From: {:?} ::: {}", $o, std::format_args!($($e),*)); + $crate::__internal_print_log_msg($crate::LogLevel::Fatal, core::format_args!("{:?}", $o), core::format_args!($($e),*)); + core::panic!("From: {:?} ::: {}", $o, core::format_args!($($e),*)); } result.ok().unwrap() } diff --git a/iceoryx2-bb/log/src/logger/mod.rs b/iceoryx2-bb/log/src/logger/mod.rs index 00e50909e..308b5372d 100644 --- a/iceoryx2-bb/log/src/logger/mod.rs +++ b/iceoryx2-bb/log/src/logger/mod.rs @@ -13,15 +13,21 @@ //! Trait which can be implemented by logger, see [`crate::logger::console::Logger`] //! for instance. +#[cfg(feature = "logger_buffer")] pub mod buffer; +#[cfg(feature = "logger_console")] pub mod console; +#[cfg(feature = "logger_file")] pub mod file; #[cfg(feature = "logger_log")] pub mod log; #[cfg(feature = "logger_tracing")] pub mod tracing; +pub mod null; + /// Sets the [`console::Logger`] as default logger +#[cfg(feature = "logger_console")] pub fn use_console_logger() -> bool { // LazyLock is only available in 'std' but since static values are never dropped in Rust, // we can also use Box::leak @@ -30,6 +36,7 @@ pub fn use_console_logger() -> bool { } /// Sets the [`file::Logger`] as default logger +#[cfg(feature = "logger_file")] pub fn use_file_logger(log_file_name: &str) -> bool { // LazyLock is only available in 'std' but since static values are never dropped in Rust, // we can also use Box::leak diff --git a/iceoryx2-bb/log/src/logger/null.rs b/iceoryx2-bb/log/src/logger/null.rs new file mode 100644 index 000000000..2d44d067e --- /dev/null +++ b/iceoryx2-bb/log/src/logger/null.rs @@ -0,0 +1,38 @@ +// Copyright (c) 2025 Contributors to the Eclipse Foundation +// +// See the NOTICE file(s) distributed with this work for additional +// information regarding copyright ownership. +// +// This program and the accompanying materials are made available under the +// terms of the Apache Software License 2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license +// which is available at https://opensource.org/licenses/MIT. +// +// SPDX-License-Identifier: Apache-2.0 OR MIT + +use crate::LogLevel; + +pub struct Logger; + +impl Logger { + pub const fn new() -> Self { + Self {} + } +} + +impl Default for Logger { + fn default() -> Self { + Logger::new() + } +} + +impl crate::Log for Logger { + fn log( + &self, + _log_level: LogLevel, + _origin: core::fmt::Arguments, + _formatted_message: core::fmt::Arguments, + ) { + // Do nothing + } +} diff --git a/iceoryx2/Cargo.toml b/iceoryx2/Cargo.toml index 73dd81a33..8f9a05d95 100644 --- a/iceoryx2/Cargo.toml +++ b/iceoryx2/Cargo.toml @@ -12,6 +12,12 @@ rust-version = { workspace = true } version = { workspace = true } [features] +default = ["std"] +std = [ + "iceoryx2-bb-log/std", + "iceoryx2-bb-log/logger_console" +] + # Enables https://crates.io/crates/log as default logger logger_log = ["iceoryx2-bb-log/logger_log"] # Enables https://crates.io/crates/tracing as default logger From 59ac8da4d1a5a5bd5823e2f6665a15eabacb73a8 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:23:38 +0200 Subject: [PATCH 03/30] [#865] Use core and alloc in iceoryx2-bb-** --- iceoryx2-bb/container/Cargo.toml | 2 - .../src/string/polymorphic_string.rs | 1 + .../container/src/string/static_string.rs | 1 + iceoryx2-bb/container/src/string/utils.rs | 3 ++ iceoryx2-bb/container/src/vector/mod.rs | 1 + .../container/src/vector/polymorphic_vec.rs | 1 + .../container/src/vector/relocatable_vec.rs | 1 + .../container/src/vector/static_vec.rs | 1 + iceoryx2-bb/derive-macros/src/lib.rs | 4 ++ iceoryx2-bb/elementary/src/lib.rs | 2 + iceoryx2-bb/elementary/src/math.rs | 2 + iceoryx2-bb/elementary/src/package_version.rs | 2 + iceoryx2-bb/linux/src/epoll.rs | 7 +++- iceoryx2-bb/linux/src/signalfd.rs | 4 +- iceoryx2-bb/lock-free/src/mpmc/container.rs | 5 +++ iceoryx2-bb/log/Cargo.toml | 15 ++++--- iceoryx2-bb/log/src/lib.rs | 9 +--- iceoryx2-bb/posix/src/config.rs | 41 ++++++++++--------- iceoryx2-bb/posix/src/deadline_queue.rs | 6 ++- iceoryx2-bb/posix/src/directory.rs | 5 +++ iceoryx2-bb/posix/src/file.rs | 16 +++++--- iceoryx2-bb/posix/src/file_descriptor_set.rs | 3 ++ iceoryx2-bb/posix/src/group.rs | 10 +++-- iceoryx2-bb/posix/src/lib.rs | 2 + iceoryx2-bb/posix/src/permission.rs | 4 ++ iceoryx2-bb/posix/src/process_state.rs | 1 + iceoryx2-bb/posix/src/read_write_mutex.rs | 20 +++++---- iceoryx2-bb/posix/src/shared_memory.rs | 29 +++++++------ iceoryx2-bb/posix/src/signal.rs | 5 +++ iceoryx2-bb/posix/src/signal_set.rs | 2 + iceoryx2-bb/posix/src/socket_ancillary.rs | 9 +++- iceoryx2-bb/posix/src/system_configuration.rs | 2 + iceoryx2-bb/posix/src/testing.rs | 11 +++-- iceoryx2-bb/posix/src/thread.rs | 5 ++- iceoryx2-bb/posix/src/udp_socket.rs | 3 ++ iceoryx2-bb/posix/src/unix_datagram_socket.rs | 11 +++-- iceoryx2-bb/posix/src/user.rs | 4 ++ iceoryx2-bb/system-types/src/base64url.rs | 3 ++ iceoryx2-bb/system-types/src/file_name.rs | 9 ++-- iceoryx2-bb/system-types/src/file_path.rs | 8 +++- iceoryx2-bb/system-types/src/group_name.rs | 3 ++ iceoryx2-bb/system-types/src/path.rs | 5 +++ iceoryx2-bb/system-types/src/user_name.rs | 3 ++ 43 files changed, 197 insertions(+), 84 deletions(-) diff --git a/iceoryx2-bb/container/Cargo.toml b/iceoryx2-bb/container/Cargo.toml index c59abffef..5ebd37f22 100644 --- a/iceoryx2-bb/container/Cargo.toml +++ b/iceoryx2-bb/container/Cargo.toml @@ -10,8 +10,6 @@ repository = { workspace = true } rust-version = { workspace = true } version = { workspace = true } -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] iceoryx2-bb-derive-macros = { workspace = true } iceoryx2-bb-elementary = { workspace = true } diff --git a/iceoryx2-bb/container/src/string/polymorphic_string.rs b/iceoryx2-bb/container/src/string/polymorphic_string.rs index bcccd6ffb..5fce3f404 100644 --- a/iceoryx2-bb/container/src/string/polymorphic_string.rs +++ b/iceoryx2-bb/container/src/string/polymorphic_string.rs @@ -50,6 +50,7 @@ //! # } //! ``` +use alloc::format; use core::{ alloc::Layout, cmp::Ordering, diff --git a/iceoryx2-bb/container/src/string/static_string.rs b/iceoryx2-bb/container/src/string/static_string.rs index a524f3654..02c69a8a9 100644 --- a/iceoryx2-bb/container/src/string/static_string.rs +++ b/iceoryx2-bb/container/src/string/static_string.rs @@ -31,6 +31,7 @@ //! println!("removed byte {:?}", some_string.remove(0)); //! ``` +use alloc::format; use core::str::FromStr; use core::{ cmp::Ordering, diff --git a/iceoryx2-bb/container/src/string/utils.rs b/iceoryx2-bb/container/src/string/utils.rs index e7945ba95..f7b7aaf99 100644 --- a/iceoryx2-bb/container/src/string/utils.rs +++ b/iceoryx2-bb/container/src/string/utils.rs @@ -10,6 +10,9 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::vec; +use alloc::vec::Vec; + /// Returns the length of a c string /// /// # Safety diff --git a/iceoryx2-bb/container/src/vector/mod.rs b/iceoryx2-bb/container/src/vector/mod.rs index 68b66492e..c6f766a2f 100644 --- a/iceoryx2-bb/container/src/vector/mod.rs +++ b/iceoryx2-bb/container/src/vector/mod.rs @@ -10,6 +10,7 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; use core::mem::MaybeUninit; use core::ops::{Deref, DerefMut}; diff --git a/iceoryx2-bb/container/src/vector/polymorphic_vec.rs b/iceoryx2-bb/container/src/vector/polymorphic_vec.rs index 9c97d8a97..12338604b 100644 --- a/iceoryx2-bb/container/src/vector/polymorphic_vec.rs +++ b/iceoryx2-bb/container/src/vector/polymorphic_vec.rs @@ -50,6 +50,7 @@ //! # } //! ``` +use alloc::format; use core::{ alloc::Layout, fmt::Debug, diff --git a/iceoryx2-bb/container/src/vector/relocatable_vec.rs b/iceoryx2-bb/container/src/vector/relocatable_vec.rs index 21eeeb411..1338e8472 100644 --- a/iceoryx2-bb/container/src/vector/relocatable_vec.rs +++ b/iceoryx2-bb/container/src/vector/relocatable_vec.rs @@ -62,6 +62,7 @@ //! unsafe { vec.init(&bump_allocator).expect("vec init failed") }; //! ``` +use alloc::format; use core::{ alloc::Layout, ops::{Deref, DerefMut}, diff --git a/iceoryx2-bb/container/src/vector/static_vec.rs b/iceoryx2-bb/container/src/vector/static_vec.rs index c62253676..df4feb772 100644 --- a/iceoryx2-bb/container/src/vector/static_vec.rs +++ b/iceoryx2-bb/container/src/vector/static_vec.rs @@ -26,6 +26,7 @@ //! my_vec.push(123); // returns false, when capacity is exceeded //! ``` +use alloc::format; use core::{fmt::Debug, mem::MaybeUninit}; use core::{ marker::PhantomData, diff --git a/iceoryx2-bb/derive-macros/src/lib.rs b/iceoryx2-bb/derive-macros/src/lib.rs index bf98877e3..1022bc355 100644 --- a/iceoryx2-bb/derive-macros/src/lib.rs +++ b/iceoryx2-bb/derive-macros/src/lib.rs @@ -16,8 +16,12 @@ //! Contains helper derive macros for iceoryx2. +extern crate alloc; extern crate proc_macro; +use alloc::format; +use alloc::vec::Vec; + use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, Data, DeriveInput, Fields, LitStr}; diff --git a/iceoryx2-bb/elementary/src/lib.rs b/iceoryx2-bb/elementary/src/lib.rs index 70f4f72c2..29db75654 100644 --- a/iceoryx2-bb/elementary/src/lib.rs +++ b/iceoryx2-bb/elementary/src/lib.rs @@ -16,6 +16,8 @@ //! Contains basic constructs which do not have any kind of dependency. +extern crate alloc; + #[macro_use] pub mod enum_gen; diff --git a/iceoryx2-bb/elementary/src/math.rs b/iceoryx2-bb/elementary/src/math.rs index d5a0fe9e3..1c62cacc8 100644 --- a/iceoryx2-bb/elementary/src/math.rs +++ b/iceoryx2-bb/elementary/src/math.rs @@ -12,6 +12,8 @@ //! Contains simplistic math functions. +use alloc::string::String; + /// Returns the required memory size when alignment adjustments are taken into account pub const fn unaligned_mem_size(array_capacity: usize) -> usize { core::mem::size_of::() * array_capacity + core::mem::align_of::() - 1 diff --git a/iceoryx2-bb/elementary/src/package_version.rs b/iceoryx2-bb/elementary/src/package_version.rs index c905fbeda..77f58987d 100644 --- a/iceoryx2-bb/elementary/src/package_version.rs +++ b/iceoryx2-bb/elementary/src/package_version.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::boxed::Box; +use alloc::format; use core::fmt::Display; /// Represents the crates version acquired through the internal environment variables set by cargo, diff --git a/iceoryx2-bb/linux/src/epoll.rs b/iceoryx2-bb/linux/src/epoll.rs index 34db796ae..50056e70f 100644 --- a/iceoryx2-bb/linux/src/epoll.rs +++ b/iceoryx2-bb/linux/src/epoll.rs @@ -48,9 +48,14 @@ //! # Ok(()) //! # } //! ``` + +extern crate alloc; + +use alloc::format; + use core::mem::MaybeUninit; +use core::sync::atomic::Ordering; use core::time::Duration; -use std::sync::atomic::Ordering; use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_log::{fail, warn}; diff --git a/iceoryx2-bb/linux/src/signalfd.rs b/iceoryx2-bb/linux/src/signalfd.rs index 5557dd13f..ccefb2e7a 100644 --- a/iceoryx2-bb/linux/src/signalfd.rs +++ b/iceoryx2-bb/linux/src/signalfd.rs @@ -39,7 +39,7 @@ //! # } //! ``` -use std::fmt::Debug; +use core::fmt::Debug; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::{ @@ -198,7 +198,7 @@ pub struct SignalInfo { } impl Debug for SignalInfo { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!( f, "SignalInfo {{ signal: {:?}, origin_pid: {}, origin_uid: {} }}", diff --git a/iceoryx2-bb/lock-free/src/mpmc/container.rs b/iceoryx2-bb/lock-free/src/mpmc/container.rs index 2db263765..3513af5b8 100644 --- a/iceoryx2-bb/lock-free/src/mpmc/container.rs +++ b/iceoryx2-bb/lock-free/src/mpmc/container.rs @@ -69,6 +69,11 @@ use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_pal_concurrency_sync::iox_atomic::{IoxAtomicBool, IoxAtomicU64}; use crate::mpmc::unique_index_set::*; + +extern crate alloc; +use alloc::vec; +use alloc::vec::Vec; + use core::alloc::Layout; use core::fmt::Debug; use core::{cell::UnsafeCell, mem::MaybeUninit, sync::atomic::Ordering}; diff --git a/iceoryx2-bb/log/Cargo.toml b/iceoryx2-bb/log/Cargo.toml index 2a6d6e255..dc3c57319 100644 --- a/iceoryx2-bb/log/Cargo.toml +++ b/iceoryx2-bb/log/Cargo.toml @@ -11,16 +11,19 @@ rust-version = { workspace = true } version = { workspace = true } [features] -default = ["std"] +default = [] std = [] -logger_buffer = [] -logger_file = [] -logger_console = [] +# Enables logging to buffer +logger_buffer = ["std"] +# Enables logging to file +logger_file = ["std"] +# Enables logging to console +logger_console = ["std"] # Enables https://crates.io/crates/log as default logger -logger_log = ["dep:log"] +logger_log = ["std", "dep:log"] # Enables https://crates.io/crates/tracing as default logger -logger_tracing = ["dep:tracing"] +logger_tracing = ["std", "dep:tracing"] [dependencies] iceoryx2-pal-concurrency-sync = { workspace = true } diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index 11c0d1aaa..daef6c98d 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -10,7 +10,6 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -#![cfg_attr(not(any(test, feature = "std")), no_std)] #![warn(clippy::alloc_instead_of_core)] #![warn(clippy::std_instead_of_alloc)] #![warn(clippy::std_instead_of_core)] @@ -179,13 +178,7 @@ static DEFAULT_LOGGER: logger::tracing::Logger = logger::tracing::Logger::new(); #[cfg(feature = "logger_log")] static DEFAULT_LOGGER: logger::log::Logger = logger::log::Logger::new(); -#[cfg(feature = "logger_file")] -static DEFAULT_LOGGER: logger::file::Logger = logger::file::Logger::new(); - -#[cfg(feature = "logger_buffer")] -static DEFAULT_LOGGER: logger::buffer::Logger = logger::buffer::Logger::new(); - -#[cfg(feature = "logger_console")] +#[cfg(not(any(feature = "logger_log", feature = "logger_tracing")))] static DEFAULT_LOGGER: logger::console::Logger = logger::console::Logger::new(); #[cfg(not(any( diff --git a/iceoryx2-bb/posix/src/config.rs b/iceoryx2-bb/posix/src/config.rs index 09164b6b7..6b4bb13ee 100644 --- a/iceoryx2-bb/posix/src/config.rs +++ b/iceoryx2-bb/posix/src/config.rs @@ -15,6 +15,9 @@ use core::time::Duration; +use alloc::{format, string::ToString}; + +use iceoryx2_bb_log::info; use iceoryx2_bb_system_types::{file_name::FileName, path::Path, user_name::UserName}; use crate::{scheduler::Scheduler, system_configuration::*}; @@ -109,9 +112,9 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool let mut is_compliant: bool = true; if mode == ComplianceCheckMode::Verbose { - println!("{HEADER_COLOR}system requirements check{COLOR_RESET}"); - println!(); - println!(" {HEADER_COLOR}minimum system{COLOR_RESET}"); + info!("{HEADER_COLOR}system requirements check{COLOR_RESET}"); + info!(""); + info!(" {HEADER_COLOR}minimum system{COLOR_RESET}"); } for i in MIN_REQUIRED_SYSTEM.iter() { let supported_value = i.0.value(); @@ -125,7 +128,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + info!( " {}{:<40}{} minimum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -141,8 +144,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(); - println!(" {HEADER_COLOR}maximum system{COLOR_RESET}"); + info!(""); + info!(" {HEADER_COLOR}maximum system{COLOR_RESET}"); } for i in MAX_REQUIRED_SYSTEM.iter() { let supported_value = i.0.value(); @@ -156,7 +159,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + info!( " {}{:<40}{} maximum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -172,8 +175,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(); - println!(" {HEADER_COLOR}minimum limits{COLOR_RESET}"); + info!(""); + info!(" {HEADER_COLOR}minimum limits{COLOR_RESET}"); } for i in MIN_REQUIRED_LIMITS.iter() { let supported_value = i.0.value(); @@ -194,7 +197,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + info!( " {}{:<40}{} minimum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -210,8 +213,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(); - println!(" {HEADER_COLOR}maximum limits{COLOR_RESET}"); + info!(""); + info!(" {HEADER_COLOR}maximum limits{COLOR_RESET}"); } for i in MAX_REQUIRED_LIMITS.iter() { let supported_value = i.0.value(); @@ -232,7 +235,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + info!( " {}{:<40}{} maximum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -248,8 +251,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(); - println!(" {HEADER_COLOR}features{COLOR_RESET}"); + info!(""); + info!(" {HEADER_COLOR}features{COLOR_RESET}"); } for i in REQUIRED_FEATURES.iter() { let is_supported = i.is_available(); @@ -262,7 +265,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + info!( " {}{:<40}{} required: {}{:<15}{} supported: {}{:<15}{}", entry_color, format!("{:?}", i), @@ -278,10 +281,10 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(); + info!(""); match !is_compliant { - true => println!(" {FAILED_COLOR}[ system non-compliant ]{COLOR_RESET}"), - false => println!(" [ system compliant ]"), + true => info!(" {FAILED_COLOR}[ system non-compliant ]{COLOR_RESET}"), + false => info!(" [ system compliant ]"), } } diff --git a/iceoryx2-bb/posix/src/deadline_queue.rs b/iceoryx2-bb/posix/src/deadline_queue.rs index b01f7ab1e..21b52c1d0 100644 --- a/iceoryx2-bb/posix/src/deadline_queue.rs +++ b/iceoryx2-bb/posix/src/deadline_queue.rs @@ -36,9 +36,13 @@ //! }); //! ``` +use core::{cell::RefCell, fmt::Debug, sync::atomic::Ordering, time::Duration}; + +use alloc::vec; +use alloc::vec::Vec; + pub use iceoryx2_bb_elementary::CallbackProgression; -use core::{cell::RefCell, fmt::Debug, sync::atomic::Ordering, time::Duration}; use iceoryx2_bb_log::fail; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64; diff --git a/iceoryx2-bb/posix/src/directory.rs b/iceoryx2-bb/posix/src/directory.rs index 8b6334209..2e3a3233e 100644 --- a/iceoryx2-bb/posix/src/directory.rs +++ b/iceoryx2-bb/posix/src/directory.rs @@ -33,6 +33,11 @@ //! //! Directory::remove(&dir_name).unwrap(); //! ``` + +use alloc::format; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_container::string::strnlen; use iceoryx2_bb_elementary::enum_gen; diff --git a/iceoryx2-bb/posix/src/file.rs b/iceoryx2-bb/posix/src/file.rs index d5aeb627a..282f3615c 100644 --- a/iceoryx2-bb/posix/src/file.rs +++ b/iceoryx2-bb/posix/src/file.rs @@ -40,13 +40,11 @@ //! } //! ``` -use crate::file_descriptor::{FileDescriptor, FileDescriptorBased, FileDescriptorManagement}; -use crate::group::Gid; -use crate::group::GroupError; -use crate::handle_errno; -use crate::ownership::OwnershipBuilder; -use crate::user::{Uid, UserError}; use core::fmt::Debug; + +use alloc::string::String; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_elementary::enum_gen; use iceoryx2_bb_log::{fail, trace, warn}; @@ -56,6 +54,12 @@ use iceoryx2_pal_posix::posix::MemZeroedStruct; use iceoryx2_pal_posix::*; pub use crate::creation_mode::CreationMode; +use crate::file_descriptor::{FileDescriptor, FileDescriptorBased, FileDescriptorManagement}; +use crate::group::Gid; +use crate::group::GroupError; +use crate::handle_errno; +use crate::ownership::OwnershipBuilder; +use crate::user::{Uid, UserError}; pub use crate::{access_mode::AccessMode, permission::*}; enum_gen! { FileRemoveError diff --git a/iceoryx2-bb/posix/src/file_descriptor_set.rs b/iceoryx2-bb/posix/src/file_descriptor_set.rs index d1a3f3de0..888dcc781 100644 --- a/iceoryx2-bb/posix/src/file_descriptor_set.rs +++ b/iceoryx2-bb/posix/src/file_descriptor_set.rs @@ -46,6 +46,9 @@ use core::{cell::UnsafeCell, fmt::Debug, time::Duration}; +use alloc::vec; +use alloc::vec::Vec; + use crate::{ clock::AsTimeval, file_descriptor::{FileDescriptor, FileDescriptorBased}, diff --git a/iceoryx2-bb/posix/src/group.rs b/iceoryx2-bb/posix/src/group.rs index 1a93e62a5..0a919f01d 100644 --- a/iceoryx2-bb/posix/src/group.rs +++ b/iceoryx2-bb/posix/src/group.rs @@ -46,17 +46,21 @@ //! } //! ``` +use alloc::format; +use alloc::string::String; +use alloc::vec; +use alloc::vec::Vec; +use core::fmt::Display; + use iceoryx2_bb_container::semantic_string::*; use iceoryx2_bb_container::string::strnlen; use iceoryx2_bb_elementary::enum_gen; +use iceoryx2_bb_log::fail; use iceoryx2_bb_system_types::{group_name::GroupName, user_name::UserName}; use iceoryx2_pal_posix::posix::{errno::Errno, MemZeroedStruct}; use iceoryx2_pal_posix::*; use crate::{config::GROUP_BUFFER_SIZE, system_configuration::*}; -use iceoryx2_bb_log::fail; - -use core::fmt::Display; enum_gen! { GroupError entry: diff --git a/iceoryx2-bb/posix/src/lib.rs b/iceoryx2-bb/posix/src/lib.rs index c1a881c0a..7b001188e 100644 --- a/iceoryx2-bb/posix/src/lib.rs +++ b/iceoryx2-bb/posix/src/lib.rs @@ -16,6 +16,8 @@ //! Abstraction of POSIX constructs with a safe API +extern crate alloc; + use barrier::BarrierCreationError; use clock::ClockError; use directory::DirectoryError; diff --git a/iceoryx2-bb/posix/src/permission.rs b/iceoryx2-bb/posix/src/permission.rs index dffed767f..e3ef47077 100644 --- a/iceoryx2-bb/posix/src/permission.rs +++ b/iceoryx2-bb/posix/src/permission.rs @@ -17,6 +17,10 @@ use core::fmt::Display; use core::ops::{BitOr, BitOrAssign, Not}; + +use alloc::string::String; +use alloc::string::ToString; + use iceoryx2_pal_posix::*; type ModeType = posix::mode_t; diff --git a/iceoryx2-bb/posix/src/process_state.rs b/iceoryx2-bb/posix/src/process_state.rs index 6170b3b08..d89e75066 100644 --- a/iceoryx2-bb/posix/src/process_state.rs +++ b/iceoryx2-bb/posix/src/process_state.rs @@ -129,6 +129,7 @@ //! } //! ``` +use alloc::format; use core::fmt::Debug; pub use iceoryx2_bb_container::semantic_string::SemanticString; diff --git a/iceoryx2-bb/posix/src/read_write_mutex.rs b/iceoryx2-bb/posix/src/read_write_mutex.rs index 8b8f0cf73..a7eb45294 100644 --- a/iceoryx2-bb/posix/src/read_write_mutex.rs +++ b/iceoryx2-bb/posix/src/read_write_mutex.rs @@ -44,15 +44,8 @@ //! }); //! }); //! ``` -pub use crate::ipc_capable::{Handle, IpcCapable}; -use crate::handle_errno; -use crate::ipc_capable::internal::{Capability, HandleStorage, IpcConstructible}; -use iceoryx2_bb_elementary::{enum_gen, scope_guard::ScopeGuardBuilder}; -use iceoryx2_bb_log::{fail, fatal_panic, warn}; -use iceoryx2_pal_posix::posix::errno::Errno; -use iceoryx2_pal_posix::posix::MemZeroedStruct; -use iceoryx2_pal_posix::*; +pub use crate::ipc_capable::{Handle, IpcCapable}; use core::marker::PhantomData; use core::{ @@ -61,6 +54,17 @@ use core::{ ops::{Deref, DerefMut}, }; +use alloc::format; + +use iceoryx2_bb_elementary::{enum_gen, scope_guard::ScopeGuardBuilder}; +use iceoryx2_bb_log::{fail, fatal_panic, warn}; +use iceoryx2_pal_posix::posix::errno::Errno; +use iceoryx2_pal_posix::posix::MemZeroedStruct; +use iceoryx2_pal_posix::*; + +use crate::handle_errno; +use crate::ipc_capable::internal::{Capability, HandleStorage, IpcConstructible}; + #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] pub enum ReadWriteMutexCreationError { InsufficientMemory, diff --git a/iceoryx2-bb/posix/src/shared_memory.rs b/iceoryx2-bb/posix/src/shared_memory.rs index 53476c6ff..012cede5a 100644 --- a/iceoryx2-bb/posix/src/shared_memory.rs +++ b/iceoryx2-bb/posix/src/shared_memory.rs @@ -63,34 +63,37 @@ //! println!("first byte: {}", shm.as_slice()[0]); //! ``` -use crate::file::{FileStatError, FileTruncateError}; -use crate::file_descriptor::*; -use crate::handle_errno; -use crate::memory_lock::{MemoryLock, MemoryLockCreationError}; -use crate::memory_mapping::{ - MappingBehavior, MemoryMapping, MemoryMappingBuilder, MemoryMappingCreationError, -}; -use crate::signal::SignalHandler; -use crate::system_configuration::Limit; +use core::ptr::NonNull; +use core::sync::atomic::Ordering; + +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string::*; use iceoryx2_bb_elementary::enum_gen; use iceoryx2_bb_log::{error, fail, fatal_panic, trace}; use iceoryx2_bb_system_types::file_name::*; use iceoryx2_bb_system_types::file_path::*; use iceoryx2_bb_system_types::path::*; +use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; use iceoryx2_pal_configuration::PATH_SEPARATOR; use iceoryx2_pal_posix::posix::errno::Errno; use iceoryx2_pal_posix::posix::POSIX_SUPPORT_ADVANCED_SIGNAL_HANDLING; use iceoryx2_pal_posix::posix::POSIX_SUPPORT_PERSISTENT_SHARED_MEMORY; use iceoryx2_pal_posix::*; -use core::ptr::NonNull; -use core::sync::atomic::Ordering; -use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; - pub use crate::access_mode::AccessMode; pub use crate::creation_mode::CreationMode; +use crate::file::{FileStatError, FileTruncateError}; +use crate::file_descriptor::*; +use crate::handle_errno; +use crate::memory_lock::{MemoryLock, MemoryLockCreationError}; +use crate::memory_mapping::{ + MappingBehavior, MemoryMapping, MemoryMappingBuilder, MemoryMappingCreationError, +}; pub use crate::permission::Permission; +use crate::signal::SignalHandler; +use crate::system_configuration::Limit; enum_gen! { SharedMemoryCreationError entry: diff --git a/iceoryx2-bb/posix/src/signal.rs b/iceoryx2-bb/posix/src/signal.rs index cc52aa534..add15f284 100644 --- a/iceoryx2-bb/posix/src/signal.rs +++ b/iceoryx2-bb/posix/src/signal.rs @@ -52,11 +52,16 @@ //! //! SignalHandler::wait_for_signal(NonFatalFetchableSignal::Terminate); //! ``` + use core::{ fmt::{Debug, Display}, time::Duration, }; +use alloc::string::ToString; +use alloc::vec; +use alloc::vec::Vec; + use crate::{ adaptive_wait::*, clock::{ClockType, NanosleepError, Time, TimeError}, diff --git a/iceoryx2-bb/posix/src/signal_set.rs b/iceoryx2-bb/posix/src/signal_set.rs index 1d2bf54f6..d287c2550 100644 --- a/iceoryx2-bb/posix/src/signal_set.rs +++ b/iceoryx2-bb/posix/src/signal_set.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::vec::Vec; + use enum_iterator::all; use iceoryx2_bb_log::fatal_panic; use iceoryx2_pal_posix::posix::{self, Errno, MemZeroedStruct}; diff --git a/iceoryx2-bb/posix/src/socket_ancillary.rs b/iceoryx2-bb/posix/src/socket_ancillary.rs index 1a286cf17..420e5ba80 100644 --- a/iceoryx2-bb/posix/src/socket_ancillary.rs +++ b/iceoryx2-bb/posix/src/socket_ancillary.rs @@ -71,11 +71,18 @@ //! // cleanup //! File::remove(&file_name); //! ``` + +use core::{fmt::Display, marker::PhantomPinned}; + +use alloc::format; +use alloc::string::ToString; +use alloc::vec; +use alloc::vec::Vec; + use crate::{ file_descriptor::FileDescriptor, group::Gid, process::*, unix_datagram_socket::UnixDatagramReceiver, user::Uid, }; -use core::{fmt::Display, marker::PhantomPinned}; use iceoryx2_bb_log::warn; use iceoryx2_pal_posix::{posix::MemZeroedStruct, *}; diff --git a/iceoryx2-bb/posix/src/system_configuration.rs b/iceoryx2-bb/posix/src/system_configuration.rs index 5c112b2ae..efd806c1e 100644 --- a/iceoryx2-bb/posix/src/system_configuration.rs +++ b/iceoryx2-bb/posix/src/system_configuration.rs @@ -13,6 +13,8 @@ //! Provides information about the POSIX [`SystemInfo`], [`Limit`]s, available [`SysOption`] and //! [`Feature`]s. +use alloc::string::ToString; + use enum_iterator::Sequence; use iceoryx2_bb_log::{fatal_panic, warn}; use iceoryx2_bb_system_types::path::Path; diff --git a/iceoryx2-bb/posix/src/testing.rs b/iceoryx2-bb/posix/src/testing.rs index 17d3f211a..55f06e315 100644 --- a/iceoryx2-bb/posix/src/testing.rs +++ b/iceoryx2-bb/posix/src/testing.rs @@ -10,15 +10,18 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::string::ToString; + +use iceoryx2_bb_container::semantic_string::SemanticString; +use iceoryx2_bb_log::fatal_panic; +use iceoryx2_bb_system_types::file_name::FileName; +use iceoryx2_bb_system_types::file_path::FilePath; + use crate::config::TEST_DIRECTORY; use crate::directory::{Directory, DirectoryCreateError}; use crate::permission::Permission; use crate::process_state::ProcessGuard; use crate::unique_system_id::UniqueSystemId; -use iceoryx2_bb_container::semantic_string::SemanticString; -use iceoryx2_bb_log::fatal_panic; -use iceoryx2_bb_system_types::file_name::FileName; -use iceoryx2_bb_system_types::file_path::FilePath; pub fn __internal_process_guard_staged_death(state: ProcessGuard) { state.staged_death(); diff --git a/iceoryx2-bb/posix/src/thread.rs b/iceoryx2-bb/posix/src/thread.rs index 2819c3643..3493614d4 100644 --- a/iceoryx2-bb/posix/src/thread.rs +++ b/iceoryx2-bb/posix/src/thread.rs @@ -84,7 +84,9 @@ use core::{cell::UnsafeCell, fmt::Debug, marker::PhantomData}; -use crate::handle_errno; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_container::string::*; use iceoryx2_bb_elementary::{enum_gen, scope_guard::ScopeGuardBuilder}; use iceoryx2_bb_log::{fail, fatal_panic, warn}; @@ -94,6 +96,7 @@ use iceoryx2_pal_posix::*; use crate::{ config::MAX_THREAD_NAME_LENGTH, + handle_errno, scheduler::Scheduler, signal::Signal, system_configuration::{Limit, SystemInfo}, diff --git a/iceoryx2-bb/posix/src/udp_socket.rs b/iceoryx2-bb/posix/src/udp_socket.rs index 8dc219f17..f94fab935 100644 --- a/iceoryx2-bb/posix/src/udp_socket.rs +++ b/iceoryx2-bb/posix/src/udp_socket.rs @@ -57,6 +57,9 @@ use core::fmt::Debug; use core::sync::atomic::Ordering; use core::time::Duration; + +use alloc::format; + use iceoryx2_bb_log::{fail, fatal_panic, trace}; use iceoryx2_bb_system_types::ipv4_address::{self, Ipv4Address}; use iceoryx2_bb_system_types::port::{self, Port}; diff --git a/iceoryx2-bb/posix/src/unix_datagram_socket.rs b/iceoryx2-bb/posix/src/unix_datagram_socket.rs index a302026ed..1da6c0023 100644 --- a/iceoryx2-bb/posix/src/unix_datagram_socket.rs +++ b/iceoryx2-bb/posix/src/unix_datagram_socket.rs @@ -117,13 +117,12 @@ //! File::remove(&file_name); //! ``` -use crate::clock::AsTimeval; -use crate::file_descriptor::{FileDescriptor, FileDescriptorBased, FileDescriptorManagement}; -use crate::file_descriptor_set::SynchronousMultiplexing; -use crate::socket_ancillary::*; use core::mem::MaybeUninit; use core::sync::atomic::Ordering; use core::{mem::size_of, time::Duration}; + +use alloc::format; + use iceoryx2_bb_container::semantic_string::*; use iceoryx2_bb_elementary::enum_gen; use iceoryx2_bb_elementary::scope_guard::ScopeGuardBuilder; @@ -132,6 +131,10 @@ use iceoryx2_bb_system_types::file_path::FilePath; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; use iceoryx2_pal_posix::posix::{errno::Errno, MemZeroedStruct}; +use crate::clock::AsTimeval; +use crate::file_descriptor::{FileDescriptor, FileDescriptorBased, FileDescriptorManagement}; +use crate::file_descriptor_set::SynchronousMultiplexing; +use crate::socket_ancillary::*; use crate::{config::UNIX_DOMAIN_SOCKET_PATH_LENGTH, file::*, permission::Permission}; pub use crate::creation_mode::CreationMode; diff --git a/iceoryx2-bb/posix/src/user.rs b/iceoryx2-bb/posix/src/user.rs index 61b0c3f24..8a15ecdcf 100644 --- a/iceoryx2-bb/posix/src/user.rs +++ b/iceoryx2-bb/posix/src/user.rs @@ -31,6 +31,10 @@ use core::ffi::CStr; use core::fmt::Display; +use alloc::format; +use alloc::string::String; +use alloc::string::ToString; + use crate::group::Gid; use crate::handle_errno; use crate::{config::PASSWD_BUFFER_SIZE, system_configuration::*}; diff --git a/iceoryx2-bb/system-types/src/base64url.rs b/iceoryx2-bb/system-types/src/base64url.rs index 6dd70d565..34f9d9926 100644 --- a/iceoryx2-bb/system-types/src/base64url.rs +++ b/iceoryx2-bb/system-types/src/base64url.rs @@ -13,6 +13,9 @@ pub use iceoryx2_bb_container::semantic_string::SemanticString; use core::hash::{Hash, Hasher}; + +use alloc::string::String; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; diff --git a/iceoryx2-bb/system-types/src/file_name.rs b/iceoryx2-bb/system-types/src/file_name.rs index d14374ace..d91de9de1 100644 --- a/iceoryx2-bb/system-types/src/file_name.rs +++ b/iceoryx2-bb/system-types/src/file_name.rs @@ -28,12 +28,15 @@ //! ``` pub use iceoryx2_bb_container::semantic_string::SemanticString; -use iceoryx2_bb_derive_macros::ZeroCopySend; -use iceoryx2_bb_elementary::static_assert::{static_assert_ge, static_assert_le}; -use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use core::hash::{Hash, Hasher}; + +use alloc::string::String; + use iceoryx2_bb_container::semantic_string; +use iceoryx2_bb_derive_macros::ZeroCopySend; +use iceoryx2_bb_elementary::static_assert::{static_assert_ge, static_assert_le}; +use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_pal_configuration::FILENAME_LENGTH; fn invalid_characters(value: &[u8]) -> bool { diff --git a/iceoryx2-bb/system-types/src/file_path.rs b/iceoryx2-bb/system-types/src/file_path.rs index 7ff3dd3d6..590ca928a 100644 --- a/iceoryx2-bb/system-types/src/file_path.rs +++ b/iceoryx2-bb/system-types/src/file_path.rs @@ -29,9 +29,10 @@ pub use iceoryx2_bb_container::semantic_string::SemanticString; -use crate::file_name::FileName; -use crate::path::Path; use core::hash::{Hash, Hasher}; + +use alloc::string::String; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_container::semantic_string::SemanticStringError; use iceoryx2_bb_derive_macros::ZeroCopySend; @@ -39,6 +40,9 @@ use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fail; use iceoryx2_pal_configuration::{PATH_LENGTH, PATH_SEPARATOR}; +use crate::file_name::FileName; +use crate::path::Path; + semantic_string! { /// Represents a file path. The restriction are choosen in a way that it is platform independent. /// This means characters/strings which would be legal on some platforms are forbidden as well. diff --git a/iceoryx2-bb/system-types/src/group_name.rs b/iceoryx2-bb/system-types/src/group_name.rs index 89a14ecdc..758735dcb 100644 --- a/iceoryx2-bb/system-types/src/group_name.rs +++ b/iceoryx2-bb/system-types/src/group_name.rs @@ -28,6 +28,9 @@ pub use iceoryx2_bb_container::semantic_string::SemanticString; use core::hash::{Hash, Hasher}; + +use alloc::string::String; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; diff --git a/iceoryx2-bb/system-types/src/path.rs b/iceoryx2-bb/system-types/src/path.rs index a67e2edb9..c9cc0b46c 100644 --- a/iceoryx2-bb/system-types/src/path.rs +++ b/iceoryx2-bb/system-types/src/path.rs @@ -30,6 +30,11 @@ pub use iceoryx2_bb_container::semantic_string::SemanticString; use core::hash::{Hash, Hasher}; + +use alloc::format; +use alloc::string::String; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_container::semantic_string::*; use iceoryx2_bb_derive_macros::ZeroCopySend; diff --git a/iceoryx2-bb/system-types/src/user_name.rs b/iceoryx2-bb/system-types/src/user_name.rs index 7681849e9..3581917be 100644 --- a/iceoryx2-bb/system-types/src/user_name.rs +++ b/iceoryx2-bb/system-types/src/user_name.rs @@ -29,6 +29,9 @@ pub use iceoryx2_bb_container::semantic_string::SemanticString; use core::hash::{Hash, Hasher}; + +use alloc::string::String; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; From aa10af9b1095a4477920573451351b5a3a61d9d3 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:24:46 +0200 Subject: [PATCH 04/30] [#865] Use core and alloc in iceoryx2-cal --- Cargo.lock | 18 ++++++++++++++ Cargo.toml | 1 + iceoryx2-cal/Cargo.toml | 1 + .../src/arc_sync_policy/mutex_protected.rs | 4 +++- .../posix_shared_memory.rs | 10 +++++--- .../communication_channel/process_local.rs | 8 +++++-- .../communication_channel/unix_datagram.rs | 4 ++++ .../dynamic_storage/posix_shared_memory.rs | 15 +++++++++--- .../src/dynamic_storage/process_local.rs | 10 ++++++-- iceoryx2-cal/src/event/common.rs | 3 +++ .../src/event/process_local_socketpair.rs | 7 +++++- .../src/event/unix_datagram_socket.rs | 3 +++ iceoryx2-cal/src/hash/mod.rs | 2 ++ iceoryx2-cal/src/hash/sha1.rs | 3 +++ iceoryx2-cal/src/monitoring/file_lock.rs | 4 ++++ iceoryx2-cal/src/monitoring/process_local.rs | 5 +++- iceoryx2-cal/src/named_concept.rs | 3 +++ iceoryx2-cal/src/reactor/epoll.rs | 3 +++ iceoryx2-cal/src/reactor/posix_select.rs | 2 ++ .../src/resizable_shared_memory/dynamic.rs | 24 ++++++++++++------- iceoryx2-cal/src/serialize/cdr.rs | 5 +++- iceoryx2-cal/src/serialize/mod.rs | 2 ++ iceoryx2-cal/src/serialize/postcard.rs | 5 +++- iceoryx2-cal/src/serialize/toml.rs | 3 +++ iceoryx2-cal/src/shared_memory/common.rs | 7 ++++-- iceoryx2-cal/src/static_storage/file.rs | 4 ++++ .../src/static_storage/process_local.rs | 7 ++++-- .../src/zero_copy_connection/common.rs | 23 +++++++++++------- 28 files changed, 149 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d0c18096..ce27011b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -967,6 +967,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1167,6 +1173,17 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + [[package]] name = "heck" version = "0.4.1" @@ -1486,6 +1503,7 @@ version = "0.7.0" dependencies = [ "cdr", "generic-tests", + "hashbrown 0.16.0", "iceoryx2-bb-container", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", diff --git a/Cargo.toml b/Cargo.toml index fee000b43..724bf109a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,6 +118,7 @@ enum-iterator = { version = "2.1.0" } better-panic = { version = "0.3.0" } colored = { version = "2.1" } generic-tests = { version = "0.1.2" } +hashbrown = { version = "0.16" } human-panic = { version = "2.0.2" } lazy_static = { version = "1.4.0" } libc = { version = "0.2.169", features = ['extra_traits'] } diff --git a/iceoryx2-cal/Cargo.toml b/iceoryx2-cal/Cargo.toml index 8e080e943..8f84007df 100644 --- a/iceoryx2-cal/Cargo.toml +++ b/iceoryx2-cal/Cargo.toml @@ -36,6 +36,7 @@ cdr = { workspace = true } toml = { workspace = true } sha1_smol = { workspace = true } tiny-fn = { workspace = true } +hashbrown = { workspace = true } [dev-dependencies] iceoryx2-bb-testing = { workspace = true } diff --git a/iceoryx2-cal/src/arc_sync_policy/mutex_protected.rs b/iceoryx2-cal/src/arc_sync_policy/mutex_protected.rs index 3b9667198..fd67cb700 100644 --- a/iceoryx2-cal/src/arc_sync_policy/mutex_protected.rs +++ b/iceoryx2-cal/src/arc_sync_policy/mutex_protected.rs @@ -10,9 +10,11 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use alloc::sync::Arc; use core::{fmt::Debug, ops::Deref}; +use alloc::format; +use alloc::sync::Arc; + use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::{ Handle, Mutex, MutexBuilder, MutexCreationError, MutexGuard, MutexHandle, MutexType, diff --git a/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs b/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs index 153e3559a..30dba66b3 100644 --- a/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs +++ b/iceoryx2-cal/src/communication_channel/posix_shared_memory.rs @@ -16,13 +16,17 @@ //! It uses internally a [`DynamicStorage`] and [`SafelyOverflowingIndexQueue`]. pub use crate::communication_channel::*; +use alloc::format; +use alloc::vec::Vec; + +use iceoryx2_bb_elementary_traits::relocatable_container::*; +use iceoryx2_bb_lock_free::spsc::safely_overflowing_index_queue::*; +use iceoryx2_bb_log::fail; + use crate::dynamic_storage::{ self, DynamicStorage, DynamicStorageBuilder, DynamicStorageCreateError, DynamicStorageOpenError, }; use crate::named_concept::*; -use iceoryx2_bb_elementary_traits::relocatable_container::*; -use iceoryx2_bb_lock_free::spsc::safely_overflowing_index_queue::*; -use iceoryx2_bb_log::fail; type SharedMemory = dynamic_storage::posix_shared_memory::Storage; type SharedMemoryBuilder<'builder> = diff --git a/iceoryx2-cal/src/communication_channel/process_local.rs b/iceoryx2-cal/src/communication_channel/process_local.rs index 82318cdd8..f5c6040f4 100644 --- a/iceoryx2-cal/src/communication_channel/process_local.rs +++ b/iceoryx2-cal/src/communication_channel/process_local.rs @@ -16,17 +16,21 @@ use crate::communication_channel::*; use crate::static_storage::file::NamedConceptConfiguration; -use alloc::sync::Arc; use core::fmt::Debug; +use alloc::format; +use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_lock_free::spsc::safely_overflowing_index_queue::*; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::*; use iceoryx2_bb_system_types::file_path::FilePath; use iceoryx2_bb_system_types::path::Path; +use hashbrown::HashMap; use once_cell::sync::Lazy; -use std::collections::HashMap; #[derive(Debug)] pub(crate) struct Management { diff --git a/iceoryx2-cal/src/communication_channel/unix_datagram.rs b/iceoryx2-cal/src/communication_channel/unix_datagram.rs index 495958845..c1b79e2ff 100644 --- a/iceoryx2-cal/src/communication_channel/unix_datagram.rs +++ b/iceoryx2-cal/src/communication_channel/unix_datagram.rs @@ -15,6 +15,10 @@ use core::{fmt::Debug, marker::PhantomData, mem::MaybeUninit}; +use alloc::format; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::{ directory::*, file::*, system_configuration::SystemInfo, unix_datagram_socket::*, diff --git a/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs b/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs index c4b432998..ce6cee8b3 100644 --- a/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs +++ b/iceoryx2-cal/src/dynamic_storage/posix_shared_memory.rs @@ -40,13 +40,19 @@ //! //! ``` pub use crate::dynamic_storage::*; -use crate::static_storage::file::NamedConceptConfiguration; -use crate::static_storage::file::NamedConceptRemoveError; +pub use core::ops::Deref; + use core::fmt::Debug; use core::marker::PhantomData; -pub use core::ops::Deref; use core::ptr::NonNull; use core::sync::atomic::Ordering; + +use alloc::format; +use alloc::string::String; +use alloc::string::ToString; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_elementary::package_version::PackageVersion; use iceoryx2_bb_log::fail; use iceoryx2_bb_log::warn; @@ -57,6 +63,9 @@ use iceoryx2_bb_posix::shared_memory::*; use iceoryx2_bb_system_types::path::Path; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64; +use crate::static_storage::file::NamedConceptConfiguration; +use crate::static_storage::file::NamedConceptRemoveError; + use self::dynamic_storage_configuration::DynamicStorageConfiguration; const INIT_PERMISSIONS: Permission = Permission::OWNER_WRITE; diff --git a/iceoryx2-cal/src/dynamic_storage/process_local.rs b/iceoryx2-cal/src/dynamic_storage/process_local.rs index 0de857972..6e31a8605 100644 --- a/iceoryx2-cal/src/dynamic_storage/process_local.rs +++ b/iceoryx2-cal/src/dynamic_storage/process_local.rs @@ -37,7 +37,6 @@ //! println!("New value: {}", reader.get().load(Ordering::Relaxed)); //! ``` -use alloc::sync::Arc; use core::alloc::Layout; use core::any::Any; use core::fmt::Debug; @@ -45,6 +44,13 @@ use core::marker::PhantomData; use core::ptr::NonNull; use core::sync::atomic::Ordering; +use alloc::format; +use alloc::string::String; +use alloc::string::ToString; +use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_elementary_traits::allocator::BaseAllocator; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_memory::heap_allocator::HeapAllocator; @@ -54,8 +60,8 @@ use iceoryx2_bb_system_types::file_path::FilePath; use iceoryx2_bb_system_types::path::Path; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; +use hashbrown::HashMap; use once_cell::sync::Lazy; -use std::collections::HashMap; pub use crate::dynamic_storage::*; use crate::named_concept::{ diff --git a/iceoryx2-cal/src/event/common.rs b/iceoryx2-cal/src/event/common.rs index ee3bf21cb..ff4780e1a 100644 --- a/iceoryx2-cal/src/event/common.rs +++ b/iceoryx2-cal/src/event/common.rs @@ -13,6 +13,9 @@ #[doc(hidden)] pub mod details { use core::{fmt::Debug, marker::PhantomData, sync::atomic::Ordering, time::Duration}; + + use alloc::vec::Vec; + use iceoryx2_bb_log::{debug, fail}; use iceoryx2_bb_memory::bump_allocator::BumpAllocator; use iceoryx2_bb_system_types::{file_name::FileName, path::Path}; diff --git a/iceoryx2-cal/src/event/process_local_socketpair.rs b/iceoryx2-cal/src/event/process_local_socketpair.rs index 35b7067c7..523bf05d8 100644 --- a/iceoryx2-cal/src/event/process_local_socketpair.rs +++ b/iceoryx2-cal/src/event/process_local_socketpair.rs @@ -11,6 +11,10 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +use alloc::vec; +use alloc::vec::Vec; + pub use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_log::{debug, fail, fatal_panic}; use iceoryx2_bb_posix::{ @@ -23,8 +27,9 @@ use iceoryx2_bb_posix::{ }, }; pub use iceoryx2_bb_system_types::{file_name::FileName, file_path::FilePath, path::Path}; + +use hashbrown::HashMap; use once_cell::sync::Lazy; -use std::collections::HashMap; use crate::named_concept::{ NamedConceptConfiguration, NamedConceptDoesExistError, NamedConceptListError, diff --git a/iceoryx2-cal/src/event/unix_datagram_socket.rs b/iceoryx2-cal/src/event/unix_datagram_socket.rs index 55ebb6e77..fcbcada76 100644 --- a/iceoryx2-cal/src/event/unix_datagram_socket.rs +++ b/iceoryx2-cal/src/event/unix_datagram_socket.rs @@ -12,6 +12,9 @@ use core::mem::MaybeUninit; +use alloc::format; +use alloc::vec::Vec; + pub use crate::event::*; use crate::static_storage::file::NamedConceptConfiguration; use iceoryx2_bb_log::fail; diff --git a/iceoryx2-cal/src/hash/mod.rs b/iceoryx2-cal/src/hash/mod.rs index daf0792f7..b5a4e233f 100644 --- a/iceoryx2-cal/src/hash/mod.rs +++ b/iceoryx2-cal/src/hash/mod.rs @@ -25,6 +25,8 @@ //! } //! ``` +use alloc::string::String; + use iceoryx2_bb_container::semantic_string::{SemanticString, SemanticStringError}; use iceoryx2_bb_system_types::base64url::Base64Url; diff --git a/iceoryx2-cal/src/hash/sha1.rs b/iceoryx2-cal/src/hash/sha1.rs index 20ee5c813..f03442228 100644 --- a/iceoryx2-cal/src/hash/sha1.rs +++ b/iceoryx2-cal/src/hash/sha1.rs @@ -12,7 +12,10 @@ //! Creates a Sha1 [`Hash`]. **Shall not be used for security critical use cases.** +use alloc::string::ToString; + use crate::hash::*; + use sha1_smol::Digest; pub struct Sha1 { diff --git a/iceoryx2-cal/src/monitoring/file_lock.rs b/iceoryx2-cal/src/monitoring/file_lock.rs index 6043019f9..e6d8606be 100644 --- a/iceoryx2-cal/src/monitoring/file_lock.rs +++ b/iceoryx2-cal/src/monitoring/file_lock.rs @@ -10,6 +10,10 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::{ directory::{Directory, DirectoryOpenError, DirectoryReadError}, diff --git a/iceoryx2-cal/src/monitoring/process_local.rs b/iceoryx2-cal/src/monitoring/process_local.rs index 824148727..a219d4192 100644 --- a/iceoryx2-cal/src/monitoring/process_local.rs +++ b/iceoryx2-cal/src/monitoring/process_local.rs @@ -10,7 +10,10 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use std::collections::HashSet; +use hashbrown::HashSet; + +use alloc::vec; +use alloc::vec::Vec; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::*; diff --git a/iceoryx2-cal/src/named_concept.rs b/iceoryx2-cal/src/named_concept.rs index 318955212..b0ce75913 100644 --- a/iceoryx2-cal/src/named_concept.rs +++ b/iceoryx2-cal/src/named_concept.rs @@ -12,6 +12,9 @@ use core::fmt::Debug; +use alloc::format; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::config::TEMP_DIRECTORY; diff --git a/iceoryx2-cal/src/reactor/epoll.rs b/iceoryx2-cal/src/reactor/epoll.rs index 8192001ec..cd766bb9e 100644 --- a/iceoryx2-cal/src/reactor/epoll.rs +++ b/iceoryx2-cal/src/reactor/epoll.rs @@ -13,6 +13,9 @@ pub use iceoryx2_bb_linux::epoll::{ Epoll, EpollBuilder, EpollCreateError, EpollEvent, EpollGuard, EventType, }; + +use alloc::format; + use iceoryx2_bb_linux::epoll::{EpollAttachmentError, EpollWaitError}; use iceoryx2_bb_log::{fail, warn}; use iceoryx2_bb_posix::file_descriptor::FileDescriptor; diff --git a/iceoryx2-cal/src/reactor/posix_select.rs b/iceoryx2-cal/src/reactor/posix_select.rs index 363a67af7..81a5b20e4 100644 --- a/iceoryx2-cal/src/reactor/posix_select.rs +++ b/iceoryx2-cal/src/reactor/posix_select.rs @@ -12,6 +12,8 @@ use core::{fmt::Debug, time::Duration}; +use alloc::format; + use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::{ clock::{nanosleep, NanosleepError}, diff --git a/iceoryx2-cal/src/resizable_shared_memory/dynamic.rs b/iceoryx2-cal/src/resizable_shared_memory/dynamic.rs index d28fe549c..5693790f2 100644 --- a/iceoryx2-cal/src/resizable_shared_memory/dynamic.rs +++ b/iceoryx2-cal/src/resizable_shared_memory/dynamic.rs @@ -16,15 +16,11 @@ use core::sync::atomic::Ordering; use core::time::Duration; use core::{fmt::Debug, marker::PhantomData}; -use crate::shared_memory::{ - AllocationStrategy, SegmentId, SharedMemoryForPoolAllocator, ShmPointer, -}; -use crate::shared_memory::{ - PointerOffset, SharedMemory, SharedMemoryBuilder, SharedMemoryCreateError, - SharedMemoryOpenError, ShmAllocator, -}; -use crate::shm_allocator::pool_allocator::PoolAllocator; -use crate::shm_allocator::ShmAllocationError; +use alloc::format; +use alloc::string::ToString; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_container::slotmap::{SlotMap, SlotMapKey}; use iceoryx2_bb_container::string::String; @@ -35,6 +31,16 @@ use iceoryx2_bb_system_types::file_name::FileName; use iceoryx2_bb_system_types::path::Path; use iceoryx2_pal_concurrency_sync::iox_atomic::{IoxAtomicU64, IoxAtomicUsize}; +use crate::shared_memory::{ + AllocationStrategy, SegmentId, SharedMemoryForPoolAllocator, ShmPointer, +}; +use crate::shared_memory::{ + PointerOffset, SharedMemory, SharedMemoryBuilder, SharedMemoryCreateError, + SharedMemoryOpenError, ShmAllocator, +}; +use crate::shm_allocator::pool_allocator::PoolAllocator; +use crate::shm_allocator::ShmAllocationError; + use super::{ NamedConcept, NamedConceptBuilder, NamedConceptDoesExistError, NamedConceptListError, NamedConceptMgmt, NamedConceptRemoveError, ResizableSharedMemory, ResizableSharedMemoryBuilder, diff --git a/iceoryx2-cal/src/serialize/cdr.rs b/iceoryx2-cal/src/serialize/cdr.rs index 65b21feec..b2c506218 100644 --- a/iceoryx2-cal/src/serialize/cdr.rs +++ b/iceoryx2-cal/src/serialize/cdr.rs @@ -13,9 +13,12 @@ //! Implements [`Serialize`] for the Common Data Representation (cdr), //! see: . +use alloc::vec::Vec; + +use iceoryx2_bb_log::fail; + use crate::serialize::Serialize; use cdr::{CdrBe, Infinite}; -use iceoryx2_bb_log::fail; use super::{DeserializeError, SerializeError}; diff --git a/iceoryx2-cal/src/serialize/mod.rs b/iceoryx2-cal/src/serialize/mod.rs index 1c8c1ebeb..fb645bf51 100644 --- a/iceoryx2-cal/src/serialize/mod.rs +++ b/iceoryx2-cal/src/serialize/mod.rs @@ -42,6 +42,8 @@ pub mod postcard; pub mod recommended; pub mod toml; +use alloc::vec::Vec; + /// Failure emitted by [`Serialize::serialize()`] #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum SerializeError { diff --git a/iceoryx2-cal/src/serialize/postcard.rs b/iceoryx2-cal/src/serialize/postcard.rs index 4d4a83834..e728ebf22 100644 --- a/iceoryx2-cal/src/serialize/postcard.rs +++ b/iceoryx2-cal/src/serialize/postcard.rs @@ -10,9 +10,12 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::serialize::Serialize; +use alloc::vec::Vec; + use iceoryx2_bb_log::fail; +use crate::serialize::Serialize; + use super::{DeserializeError, SerializeError}; pub struct Postcard {} diff --git a/iceoryx2-cal/src/serialize/toml.rs b/iceoryx2-cal/src/serialize/toml.rs index 0cb1e8070..a354ffe03 100644 --- a/iceoryx2-cal/src/serialize/toml.rs +++ b/iceoryx2-cal/src/serialize/toml.rs @@ -12,6 +12,9 @@ //! Implements [`Serialize`] for TOML files. +use alloc::string::String; +use alloc::vec::Vec; + use iceoryx2_bb_log::fail; use crate::serialize::Serialize; diff --git a/iceoryx2-cal/src/shared_memory/common.rs b/iceoryx2-cal/src/shared_memory/common.rs index 894ff1f1c..6dbb607f7 100644 --- a/iceoryx2-cal/src/shared_memory/common.rs +++ b/iceoryx2-cal/src/shared_memory/common.rs @@ -14,8 +14,6 @@ use core::marker::PhantomData; use core::mem::MaybeUninit; use core::{alloc::Layout, fmt::Debug}; -use crate::dynamic_storage::*; -pub use crate::shared_memory::*; use iceoryx2_bb_elementary_traits::allocator::BaseAllocator; use iceoryx2_bb_log::{debug, fail}; use iceoryx2_bb_posix::system_configuration::SystemInfo; @@ -23,12 +21,17 @@ use iceoryx2_bb_system_types::file_name::FileName; use iceoryx2_bb_system_types::file_path::FilePath; use iceoryx2_bb_system_types::path::Path; +use crate::dynamic_storage::*; +pub use crate::shared_memory::*; + use crate::static_storage::file::{ NamedConcept, NamedConceptBuilder, NamedConceptConfiguration, NamedConceptMgmt, }; #[doc(hidden)] pub mod details { + use alloc::vec::Vec; + use iceoryx2_bb_memory::bump_allocator::BumpAllocator; use pool_allocator::PoolAllocator; diff --git a/iceoryx2-cal/src/static_storage/file.rs b/iceoryx2-cal/src/static_storage/file.rs index 392d21a5a..da0342809 100644 --- a/iceoryx2-cal/src/static_storage/file.rs +++ b/iceoryx2-cal/src/static_storage/file.rs @@ -46,6 +46,10 @@ use core::sync::atomic::Ordering; +use alloc::format; +use alloc::vec; +use alloc::vec::Vec; + pub use crate::named_concept::*; pub use crate::static_storage::*; diff --git a/iceoryx2-cal/src/static_storage/process_local.rs b/iceoryx2-cal/src/static_storage/process_local.rs index 27f7f5413..892387b72 100644 --- a/iceoryx2-cal/src/static_storage/process_local.rs +++ b/iceoryx2-cal/src/static_storage/process_local.rs @@ -41,16 +41,19 @@ pub use crate::named_concept::*; pub use crate::static_storage::*; -use alloc::sync::Arc; use core::sync::atomic::Ordering; +use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::adaptive_wait::AdaptiveWaitBuilder; use iceoryx2_bb_posix::mutex::*; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; +use hashbrown::HashMap; use once_cell::sync::Lazy; -use std::collections::HashMap; #[derive(Debug)] struct StorageContent { diff --git a/iceoryx2-cal/src/zero_copy_connection/common.rs b/iceoryx2-cal/src/zero_copy_connection/common.rs index 19a4ce18c..3425f2cb5 100644 --- a/iceoryx2-cal/src/zero_copy_connection/common.rs +++ b/iceoryx2-cal/src/zero_copy_connection/common.rs @@ -16,25 +16,30 @@ pub mod details { use core::fmt::Debug; use core::marker::PhantomData; use core::sync::atomic::Ordering; + + use alloc::vec; + use alloc::vec::Vec; + + use iceoryx2_bb_container::vector::relocatable_vec::*; use iceoryx2_bb_elementary_traits::allocator::{AllocationError, BaseAllocator}; + use iceoryx2_bb_elementary_traits::relocatable_container::RelocatableContainer; + use iceoryx2_bb_lock_free::spsc::{ + index_queue::RelocatableIndexQueue, + safely_overflowing_index_queue::RelocatableSafelyOverflowingIndexQueue, + }; + use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_memory::bump_allocator::BumpAllocator; + use iceoryx2_bb_posix::adaptive_wait::AdaptiveWaitBuilder; use iceoryx2_pal_concurrency_sync::iox_atomic::{IoxAtomicU64, IoxAtomicU8, IoxAtomicUsize}; + pub use crate::zero_copy_connection::*; + use crate::dynamic_storage::{ DynamicStorage, DynamicStorageBuilder, DynamicStorageCreateError, DynamicStorageOpenError, DynamicStorageOpenOrCreateError, }; use crate::named_concept::*; use crate::shared_memory::SegmentId; - pub use crate::zero_copy_connection::*; - use iceoryx2_bb_container::vector::relocatable_vec::*; - use iceoryx2_bb_elementary_traits::relocatable_container::RelocatableContainer; - use iceoryx2_bb_lock_free::spsc::{ - index_queue::RelocatableIndexQueue, - safely_overflowing_index_queue::RelocatableSafelyOverflowingIndexQueue, - }; - use iceoryx2_bb_log::{fail, fatal_panic}; - use iceoryx2_bb_posix::adaptive_wait::AdaptiveWaitBuilder; use self::used_chunk_list::RelocatableUsedChunkList; From 9708735e793c97a102323a138063e1e2065a4510 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:25:57 +0200 Subject: [PATCH 05/30] [#865] Use core and alloc in iceoryx2 --- Cargo.lock | 1 + iceoryx2/Cargo.toml | 21 +++++++-- iceoryx2/src/config.rs | 3 ++ iceoryx2/src/node/mod.rs | 35 +++++++++------ iceoryx2/src/node/node_name.rs | 6 ++- iceoryx2/src/port/details/receiver.rs | 28 ++++++------ iceoryx2/src/port/details/segment_state.rs | 2 + iceoryx2/src/port/details/sender.rs | 5 ++- iceoryx2/src/port/listener.rs | 9 ++-- iceoryx2/src/port/notifier.rs | 25 ++++++----- iceoryx2/src/port/port_identifiers.rs | 2 + iceoryx2/src/port/publisher.rs | 43 +++++++++++-------- iceoryx2/src/port/reader.rs | 4 +- iceoryx2/src/port/writer.rs | 4 +- iceoryx2/src/prelude.rs | 2 + iceoryx2/src/service/attribute.rs | 4 ++ iceoryx2/src/service/builder/blackboard.rs | 39 ++++++++++------- iceoryx2/src/service/builder/event.rs | 14 +++--- iceoryx2/src/service/builder/mod.rs | 17 +++++--- .../src/service/builder/publish_subscribe.rs | 21 +++++---- .../src/service/builder/request_response.rs | 15 ++++--- iceoryx2/src/service/mod.rs | 7 ++- iceoryx2/src/service/naming_scheme.rs | 5 ++- iceoryx2/src/service/port_factory/client.rs | 15 ++++--- .../src/service/port_factory/publisher.rs | 5 ++- iceoryx2/src/service/port_factory/reader.rs | 10 +++-- iceoryx2/src/service/port_factory/server.rs | 15 ++++--- .../src/service/port_factory/subscriber.rs | 2 + iceoryx2/src/service/port_factory/writer.rs | 10 +++-- iceoryx2/src/service/service_id.rs | 3 ++ iceoryx2/src/service/service_name.rs | 6 ++- .../src/service/stale_resource_cleanup.rs | 3 ++ iceoryx2/src/service/static_config/mod.rs | 3 ++ iceoryx2/src/testing.rs | 2 + iceoryx2/src/waitset.rs | 6 ++- 35 files changed, 262 insertions(+), 130 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce27011b1..7cbad4a96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1293,6 +1293,7 @@ dependencies = [ name = "iceoryx2" version = "0.7.0" dependencies = [ + "hashbrown 0.16.0", "iceoryx2-bb-container", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", diff --git a/iceoryx2/Cargo.toml b/iceoryx2/Cargo.toml index 8f9a05d95..25362f543 100644 --- a/iceoryx2/Cargo.toml +++ b/iceoryx2/Cargo.toml @@ -14,14 +14,26 @@ version = { workspace = true } [features] default = ["std"] std = [ - "iceoryx2-bb-log/std", - "iceoryx2-bb-log/logger_console" + "logger_buffer", + "logger_console", + "logger_file" ] +# Enables logging to buffer +logger_buffer = ["iceoryx2-bb-log/logger_buffer"] +# Enables logging to file +logger_file = ["iceoryx2-bb-log/logger_file"] +# Enables logging to console +logger_console = ["iceoryx2-bb-log/logger_console"] # Enables https://crates.io/crates/log as default logger -logger_log = ["iceoryx2-bb-log/logger_log"] +logger_log = [ + "iceoryx2-bb-log/logger_log" +] # Enables https://crates.io/crates/tracing as default logger -logger_tracing = ["iceoryx2-bb-log/logger_tracing"] +logger_tracing = [ + "iceoryx2-bb-log/logger_tracing" +] + # The permissions of all resources will be set to read, write, execute for everyone. # This shall not be used in production and is meant to be enabled in a docker environment # with inconsistent user configuration. @@ -47,6 +59,7 @@ iceoryx2-cal = { workspace = true } iceoryx2-pal-concurrency-sync = { workspace = true } iceoryx2-pal-configuration = { workspace = true } +hashbrown = { workspace = true } serde = { workspace = true } toml = { workspace = true } tiny-fn = { workspace = true } diff --git a/iceoryx2/src/config.rs b/iceoryx2/src/config.rs index 3ae02fa90..31aeac462 100644 --- a/iceoryx2/src/config.rs +++ b/iceoryx2/src/config.rs @@ -70,6 +70,9 @@ //! ``` use core::time::Duration; + +use alloc::string::String; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_elementary::{lazy_singleton::*, CallbackProgression}; use iceoryx2_bb_posix::{ diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index a93c83d7b..9d4d4de6a 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -145,22 +145,18 @@ pub mod node_name; #[doc(hidden)] pub mod testing; -use crate::node::node_name::NodeName; -use crate::service::builder::{Builder, OpenDynamicStorageFailure}; -use crate::service::config_scheme::{ - node_details_path, node_monitoring_config, service_tag_config, -}; -use crate::service::service_id::ServiceId; -use crate::service::service_name::ServiceName; -use crate::service::{ - self, remove_service_tag, remove_static_service_config, ServiceRemoveNodeError, -}; -use crate::signal_handling_mode::SignalHandlingMode; -use crate::{config::Config, service::config_scheme::node_details_config}; use core::cell::UnsafeCell; use core::marker::PhantomData; use core::sync::atomic::Ordering; use core::time::Duration; + +use alloc::format; +use alloc::string::String; +use alloc::string::ToString; +use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary::CallbackProgression; @@ -178,9 +174,20 @@ use iceoryx2_cal::{ }; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; -use alloc::sync::Arc; +use crate::node::node_name::NodeName; +use crate::service::builder::{Builder, OpenDynamicStorageFailure}; +use crate::service::config_scheme::{ + node_details_path, node_monitoring_config, service_tag_config, +}; +use crate::service::service_id::ServiceId; +use crate::service::service_name::ServiceName; +use crate::service::{ + self, remove_service_tag, remove_static_service_config, ServiceRemoveNodeError, +}; +use crate::signal_handling_mode::SignalHandlingMode; +use crate::{config::Config, service::config_scheme::node_details_config}; -use std::collections::HashMap; +use hashbrown::HashMap; use std::sync::Mutex; /// The system-wide unique id of a [`Node`] diff --git a/iceoryx2/src/node/node_name.rs b/iceoryx2/src/node/node_name.rs index f360e4382..1b42a3f72 100644 --- a/iceoryx2/src/node/node_name.rs +++ b/iceoryx2/src/node/node_name.rs @@ -10,9 +10,13 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::constants::MAX_NODE_NAME_LENGTH; +use alloc::format; + use iceoryx2_bb_container::{semantic_string::SemanticStringError, string::*}; use iceoryx2_bb_log::fail; + +use crate::constants::MAX_NODE_NAME_LENGTH; + use serde::{de::Visitor, Deserialize, Serialize}; type NodeNameString = StaticString; diff --git a/iceoryx2/src/port/details/receiver.rs b/iceoryx2/src/port/details/receiver.rs index d16daafaa..e2f1ff6bc 100644 --- a/iceoryx2/src/port/details/receiver.rs +++ b/iceoryx2/src/port/details/receiver.rs @@ -12,19 +12,9 @@ use core::cell::UnsafeCell; -use super::channel_management::ChannelManagement; -use super::channel_management::INVALID_CHANNEL_STATE; -use super::chunk::Chunk; -use super::chunk_details::ChunkDetails; -use super::data_segment::{DataSegmentType, DataSegmentView}; -use crate::port::update_connections::ConnectionFailure; -use crate::port::{DegradationAction, DegradationCallback, ReceiveError}; -use crate::service::naming_scheme::data_segment_name; -use crate::service::static_config::message_type_details::MessageTypeDetails; -use crate::service::NoResource; -use crate::service::ServiceState; -use crate::service::{self, config_scheme::connection_config, naming_scheme::connection_name}; +use alloc::format; use alloc::sync::Arc; + use iceoryx2_bb_container::slotmap::SlotMap; use iceoryx2_bb_container::slotmap::SlotMapKey; use iceoryx2_bb_container::vector::polymorphic_vec::*; @@ -35,6 +25,20 @@ use iceoryx2_bb_memory::heap_allocator::HeapAllocator; use iceoryx2_cal::named_concept::NamedConceptBuilder; use iceoryx2_cal::zero_copy_connection::*; +use crate::port::update_connections::ConnectionFailure; +use crate::port::{DegradationAction, DegradationCallback, ReceiveError}; +use crate::service::naming_scheme::data_segment_name; +use crate::service::static_config::message_type_details::MessageTypeDetails; +use crate::service::NoResource; +use crate::service::ServiceState; +use crate::service::{self, config_scheme::connection_config, naming_scheme::connection_name}; + +use super::channel_management::ChannelManagement; +use super::channel_management::INVALID_CHANNEL_STATE; +use super::chunk::Chunk; +use super::chunk_details::ChunkDetails; +use super::data_segment::{DataSegmentType, DataSegmentView}; + #[derive(Clone, Copy)] pub(crate) struct SenderDetails { pub(crate) port_id: u128, diff --git a/iceoryx2/src/port/details/segment_state.rs b/iceoryx2/src/port/details/segment_state.rs index 1cb3a4c8f..0d82ed9a3 100644 --- a/iceoryx2/src/port/details/segment_state.rs +++ b/iceoryx2/src/port/details/segment_state.rs @@ -12,6 +12,8 @@ use core::sync::atomic::Ordering; +use alloc::vec::Vec; + use iceoryx2_pal_concurrency_sync::iox_atomic::{IoxAtomicU64, IoxAtomicUsize}; #[derive(Debug)] diff --git a/iceoryx2/src/port/details/sender.rs b/iceoryx2/src/port/details/sender.rs index 13e48f6d5..b9ae063e7 100644 --- a/iceoryx2/src/port/details/sender.rs +++ b/iceoryx2/src/port/details/sender.rs @@ -10,11 +10,14 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use alloc::sync::Arc; use core::alloc::Layout; use core::cell::UnsafeCell; use core::sync::atomic::Ordering; +use alloc::format; +use alloc::sync::Arc; +use alloc::vec::Vec; + use iceoryx2_bb_elementary::cyclic_tagger::*; use iceoryx2_bb_log::{error, fail, fatal_panic, warn}; use iceoryx2_cal::named_concept::NamedConceptBuilder; diff --git a/iceoryx2/src/port/listener.rs b/iceoryx2/src/port/listener.rs index 75c138f9c..f1c9a1ca4 100644 --- a/iceoryx2/src/port/listener.rs +++ b/iceoryx2/src/port/listener.rs @@ -58,6 +58,12 @@ //! # } //! ``` +use core::sync::atomic::Ordering; +use core::time::Duration; + +use alloc::format; +use alloc::sync::Arc; + use iceoryx2_bb_lock_free::mpmc::container::ContainerHandle; use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::file_descriptor::{FileDescriptor, FileDescriptorBased}; @@ -73,9 +79,6 @@ use crate::service::dynamic_config::event::ListenerDetails; use crate::service::naming_scheme::event_concept_name; use crate::service::{NoResource, ServiceState}; use crate::{port::port_identifiers::UniqueListenerId, service}; -use alloc::sync::Arc; -use core::sync::atomic::Ordering; -use core::time::Duration; use super::event_id::EventId; diff --git a/iceoryx2/src/port/notifier.rs b/iceoryx2/src/port/notifier.rs index 8b03c5c9c..c00c41443 100644 --- a/iceoryx2/src/port/notifier.rs +++ b/iceoryx2/src/port/notifier.rs @@ -35,7 +35,20 @@ //! # } //! ``` -use super::{event_id::EventId, port_identifiers::UniqueListenerId}; +use core::{cell::UnsafeCell, sync::atomic::Ordering, time::Duration}; + +use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; + +use iceoryx2_bb_elementary::CallbackProgression; +use iceoryx2_bb_lock_free::mpmc::container::{ContainerHandle, ContainerState}; +use iceoryx2_bb_log::{debug, fail, warn}; +use iceoryx2_cal::{ + arc_sync_policy::ArcSyncPolicy, dynamic_storage::DynamicStorage, event::NotifierBuilder, +}; +use iceoryx2_cal::{event::Event, named_concept::NamedConceptBuilder}; + use crate::{ node::NodeId, port::{port_identifiers::UniqueNotifierId, update_connections::UpdateConnections}, @@ -47,16 +60,8 @@ use crate::{ NoResource, ServiceState, }, }; -use iceoryx2_bb_elementary::CallbackProgression; -use iceoryx2_bb_lock_free::mpmc::container::{ContainerHandle, ContainerState}; -use iceoryx2_bb_log::{debug, fail, warn}; -use iceoryx2_cal::{ - arc_sync_policy::ArcSyncPolicy, dynamic_storage::DynamicStorage, event::NotifierBuilder, -}; -use iceoryx2_cal::{event::Event, named_concept::NamedConceptBuilder}; -use alloc::sync::Arc; -use core::{cell::UnsafeCell, sync::atomic::Ordering, time::Duration}; +use super::{event_id::EventId, port_identifiers::UniqueListenerId}; /// Failures that can occur when a new [`Notifier`] is created with the /// [`crate::service::port_factory::notifier::PortFactoryNotifier`]. diff --git a/iceoryx2/src/port/port_identifiers.rs b/iceoryx2/src/port/port_identifiers.rs index ccec2c945..f98301476 100644 --- a/iceoryx2/src/port/port_identifiers.rs +++ b/iceoryx2/src/port/port_identifiers.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; + use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fatal_panic; diff --git a/iceoryx2/src/port/publisher.rs b/iceoryx2/src/port/publisher.rs index 5d57d86ea..cd3c6c329 100644 --- a/iceoryx2/src/port/publisher.rs +++ b/iceoryx2/src/port/publisher.rs @@ -101,30 +101,15 @@ //! # } //! ``` -use super::details::data_segment::{DataSegment, DataSegmentType}; -use super::details::segment_state::SegmentState; -use super::port_identifiers::UniquePublisherId; -use super::{LoanError, SendError}; -use crate::port::details::sender::*; -use crate::port::update_connections::{ConnectionFailure, UpdateConnections}; -use crate::prelude::UnableToDeliverStrategy; -use crate::raw_sample::RawSampleMut; -use crate::sample_mut::SampleMut; -use crate::sample_mut_uninit::SampleMutUninit; -use crate::service::builder::{CustomHeaderMarker, CustomPayloadMarker}; -use crate::service::dynamic_config::publish_subscribe::{PublisherDetails, SubscriberDetails}; -use crate::service::header::publish_subscribe::Header; -use crate::service::naming_scheme::data_segment_name; -use crate::service::port_factory::publisher::LocalPublisherConfig; -use crate::service::static_config::message_type_details::TypeVariant; -use crate::service::static_config::publish_subscribe; -use crate::service::{self, NoResource, ServiceState}; -use alloc::sync::Arc; use core::any::TypeId; use core::cell::UnsafeCell; use core::fmt::Debug; use core::sync::atomic::Ordering; use core::{marker::PhantomData, mem::MaybeUninit}; + +use alloc::sync::Arc; +use alloc::vec::Vec; + use iceoryx2_bb_container::queue::Queue; use iceoryx2_bb_elementary::cyclic_tagger::CyclicTagger; use iceoryx2_bb_elementary::CallbackProgression; @@ -140,6 +125,26 @@ use iceoryx2_cal::zero_copy_connection::{ }; use iceoryx2_pal_concurrency_sync::iox_atomic::{IoxAtomicBool, IoxAtomicUsize}; +use crate::port::details::sender::*; +use crate::port::update_connections::{ConnectionFailure, UpdateConnections}; +use crate::prelude::UnableToDeliverStrategy; +use crate::raw_sample::RawSampleMut; +use crate::sample_mut::SampleMut; +use crate::sample_mut_uninit::SampleMutUninit; +use crate::service::builder::{CustomHeaderMarker, CustomPayloadMarker}; +use crate::service::dynamic_config::publish_subscribe::{PublisherDetails, SubscriberDetails}; +use crate::service::header::publish_subscribe::Header; +use crate::service::naming_scheme::data_segment_name; +use crate::service::port_factory::publisher::LocalPublisherConfig; +use crate::service::static_config::message_type_details::TypeVariant; +use crate::service::static_config::publish_subscribe; +use crate::service::{self, NoResource, ServiceState}; + +use super::details::data_segment::{DataSegment, DataSegmentType}; +use super::details::segment_state::SegmentState; +use super::port_identifiers::UniquePublisherId; +use super::{LoanError, SendError}; + /// Defines a failure that can occur when a [`Publisher`] is created with /// [`crate::service::port_factory::publisher::PortFactoryPublisher`]. #[derive(Debug, PartialEq, Eq, Copy, Clone)] diff --git a/iceoryx2/src/port/reader.rs b/iceoryx2/src/port/reader.rs index 4f104f6e8..066e4f494 100644 --- a/iceoryx2/src/port/reader.rs +++ b/iceoryx2/src/port/reader.rs @@ -101,7 +101,7 @@ pub enum ReaderCreateError { impl core::fmt::Display for ReaderCreateError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - std::write!(f, "ReaderCreateError::{self:?}") + write!(f, "ReaderCreateError::{self:?}") } } @@ -279,7 +279,7 @@ pub enum EntryHandleError { impl core::fmt::Display for EntryHandleError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - std::write!(f, "EntryHandleError::{self:?}") + write!(f, "EntryHandleError::{self:?}") } } diff --git a/iceoryx2/src/port/writer.rs b/iceoryx2/src/port/writer.rs index 875347fa8..32a5aaee7 100644 --- a/iceoryx2/src/port/writer.rs +++ b/iceoryx2/src/port/writer.rs @@ -108,7 +108,7 @@ pub enum WriterCreateError { impl core::fmt::Display for WriterCreateError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - std::write!(f, "WriterCreateError::{self:?}") + write!(f, "WriterCreateError::{self:?}") } } @@ -287,7 +287,7 @@ pub enum EntryHandleMutError { impl core::fmt::Display for EntryHandleMutError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - std::write!(f, "EntryHandleMutError::{self:?}") + write!(f, "EntryHandleMutError::{self:?}") } } diff --git a/iceoryx2/src/prelude.rs b/iceoryx2/src/prelude.rs index 8bc7806ae..4a71054dd 100644 --- a/iceoryx2/src/prelude.rs +++ b/iceoryx2/src/prelude.rs @@ -30,7 +30,9 @@ pub use iceoryx2_bb_elementary::CallbackProgression; pub use iceoryx2_bb_elementary_traits::placement_default::PlacementDefault; pub use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; pub use iceoryx2_bb_log::set_log_level; +#[cfg(feature = "std")] pub use iceoryx2_bb_log::set_log_level_from_env_or; +#[cfg(feature = "std")] pub use iceoryx2_bb_log::set_log_level_from_env_or_default; pub use iceoryx2_bb_log::LogLevel; pub use iceoryx2_bb_posix::file_descriptor::{FileDescriptor, FileDescriptorBased}; diff --git a/iceoryx2/src/service/attribute.rs b/iceoryx2/src/service/attribute.rs index 7207c29f9..a9c90ec3a 100644 --- a/iceoryx2/src/service/attribute.rs +++ b/iceoryx2/src/service/attribute.rs @@ -113,6 +113,8 @@ mod key { use core::hash::Hash; use core::hash::Hasher; + use alloc::string::String; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_derive_macros::ZeroCopySend; @@ -146,6 +148,8 @@ mod value { use core::hash::Hash; use core::hash::Hasher; + use alloc::string::String; + use iceoryx2_bb_container::semantic_string; use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_derive_macros::ZeroCopySend; diff --git a/iceoryx2/src/service/builder/blackboard.rs b/iceoryx2/src/service/builder/blackboard.rs index 1d4e62457..8f8beaead 100644 --- a/iceoryx2/src/service/builder/blackboard.rs +++ b/iceoryx2/src/service/builder/blackboard.rs @@ -14,24 +14,16 @@ //! //! See [`crate::service`] //! -use self::attribute::{AttributeSpecifier, AttributeVerifier}; -use super::{OpenDynamicStorageFailure, ServiceState}; -use crate::constants::{MAX_BLACKBOARD_KEY_ALIGNMENT, MAX_BLACKBOARD_KEY_SIZE}; -use crate::service; -use crate::service::builder::CustomKeyMarker; -use crate::service::config_scheme::{blackboard_data_config, blackboard_mgmt_config}; -use crate::service::dynamic_config::blackboard::DynamicConfigSettings; -use crate::service::dynamic_config::MessagingPatternSettings; -use crate::service::naming_scheme::blackboard_name; -use crate::service::port_factory::blackboard; -use crate::service::static_config::message_type_details::TypeDetail; -use crate::service::static_config::messaging_pattern::MessagingPattern; -use crate::service::*; -use alloc::rc::Rc; -use builder::RETRY_LIMIT; + use core::alloc::Layout; use core::hash::Hash; use core::marker::PhantomData; + +use alloc::boxed::Box; +use alloc::format; +use alloc::rc::Rc; +use alloc::vec::Vec; + use iceoryx2_bb_container::flatmap::RelocatableFlatMap; use iceoryx2_bb_container::queue::RelocatableContainer; use iceoryx2_bb_container::string::*; @@ -46,6 +38,23 @@ use iceoryx2_cal::dynamic_storage::DynamicStorageCreateError; use iceoryx2_cal::shared_memory::{SharedMemory, SharedMemoryBuilder}; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64; +use crate::constants::{MAX_BLACKBOARD_KEY_ALIGNMENT, MAX_BLACKBOARD_KEY_SIZE}; +use crate::service; +use crate::service::builder::CustomKeyMarker; +use crate::service::config_scheme::{blackboard_data_config, blackboard_mgmt_config}; +use crate::service::dynamic_config::blackboard::DynamicConfigSettings; +use crate::service::dynamic_config::MessagingPatternSettings; +use crate::service::naming_scheme::blackboard_name; +use crate::service::port_factory::blackboard; +use crate::service::static_config::message_type_details::TypeDetail; +use crate::service::static_config::messaging_pattern::MessagingPattern; +use crate::service::*; + +use super::{OpenDynamicStorageFailure, ServiceState}; + +use self::attribute::{AttributeSpecifier, AttributeVerifier}; +use builder::RETRY_LIMIT; + #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] enum ServiceAvailabilityState { ServiceState(ServiceState), diff --git a/iceoryx2/src/service/builder/event.rs b/iceoryx2/src/service/builder/event.rs index c15a77854..11263eb1a 100644 --- a/iceoryx2/src/service/builder/event.rs +++ b/iceoryx2/src/service/builder/event.rs @@ -15,19 +15,23 @@ //! See [`crate::service`] //! pub use crate::port::event_id::EventId; + +use alloc::format; + +use iceoryx2_bb_log::{fail, fatal_panic}; +use iceoryx2_bb_posix::clock::Time; +use iceoryx2_cal::dynamic_storage::DynamicStorageCreateError; + use crate::service::builder::OpenDynamicStorageFailure; use crate::service::dynamic_config::MessagingPatternSettings; use crate::service::port_factory::event; use crate::service::static_config::messaging_pattern::MessagingPattern; use crate::service::*; use crate::service::{self, dynamic_config::event::DynamicConfigSettings}; -use builder::RETRY_LIMIT; -use iceoryx2_bb_log::{fail, fatal_panic}; -use iceoryx2_bb_posix::clock::Time; -use iceoryx2_cal::dynamic_storage::DynamicStorageCreateError; -use static_config::event::Deadline; use self::attribute::{AttributeSpecifier, AttributeVerifier}; +use builder::RETRY_LIMIT; +use static_config::event::Deadline; use super::ServiceState; diff --git a/iceoryx2/src/service/builder/mod.rs b/iceoryx2/src/service/builder/mod.rs index 11d81e265..0c2caf0bc 100644 --- a/iceoryx2/src/service/builder/mod.rs +++ b/iceoryx2/src/service/builder/mod.rs @@ -26,15 +26,14 @@ pub mod request_response; /// Builder for [`MessagingPattern::Blackboard`](crate::service::messaging_pattern::MessagingPattern::Blackboard) pub mod blackboard; -use crate::node::SharedNode; -use crate::service; -use crate::service::dynamic_config::DynamicConfig; -use crate::service::dynamic_config::RegisterNodeResult; -use crate::service::static_config::*; -use alloc::sync::Arc; use core::fmt::Debug; use core::hash::Hash; use core::marker::PhantomData; + +use alloc::string::String; +use alloc::sync::Arc; +use alloc::vec; + use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary::enum_gen; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; @@ -52,6 +51,12 @@ use iceoryx2_cal::named_concept::NamedConceptRemoveError; use iceoryx2_cal::serialize::Serialize; use iceoryx2_cal::static_storage::*; +use crate::node::SharedNode; +use crate::service; +use crate::service::dynamic_config::DynamicConfig; +use crate::service::dynamic_config::RegisterNodeResult; +use crate::service::static_config::*; + use super::config_scheme::dynamic_config_storage_config; use super::config_scheme::service_tag_config; use super::config_scheme::static_config_storage_config; diff --git a/iceoryx2/src/service/builder/publish_subscribe.rs b/iceoryx2/src/service/builder/publish_subscribe.rs index d74814990..483fc6b42 100644 --- a/iceoryx2/src/service/builder/publish_subscribe.rs +++ b/iceoryx2/src/service/builder/publish_subscribe.rs @@ -16,13 +16,8 @@ //! use core::marker::PhantomData; -use crate::service::dynamic_config::publish_subscribe::DynamicConfigSettings; -use crate::service::header::publish_subscribe::Header; -use crate::service::port_factory::publish_subscribe; -use crate::service::static_config::messaging_pattern::MessagingPattern; -use crate::service::*; -use crate::service::{self, dynamic_config::MessagingPatternSettings}; -use builder::RETRY_LIMIT; +use alloc::format; + use iceoryx2_bb_elementary::alignment::Alignment; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::{fail, fatal_panic, warn}; @@ -30,12 +25,20 @@ use iceoryx2_cal::dynamic_storage::DynamicStorageCreateError; use iceoryx2_cal::serialize::Serialize; use iceoryx2_cal::static_storage::StaticStorageLocked; +use crate::service::dynamic_config::publish_subscribe::DynamicConfigSettings; +use crate::service::header::publish_subscribe::Header; +use crate::service::port_factory::publish_subscribe; +use crate::service::static_config::messaging_pattern::MessagingPattern; +use crate::service::*; +use crate::service::{self, dynamic_config::MessagingPatternSettings}; + +use super::{CustomHeaderMarker, CustomPayloadMarker, OpenDynamicStorageFailure, ServiceState}; + use self::{ attribute::{AttributeSpecifier, AttributeVerifier}, message_type_details::{MessageTypeDetails, TypeDetail, TypeVariant}, }; - -use super::{CustomHeaderMarker, CustomPayloadMarker, OpenDynamicStorageFailure, ServiceState}; +use builder::RETRY_LIMIT; /// Errors that can occur when an existing [`MessagingPattern::PublishSubscribe`] [`Service`] shall be opened. #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] diff --git a/iceoryx2/src/service/builder/request_response.rs b/iceoryx2/src/service/builder/request_response.rs index 0b08ce5a1..2cfd0aaa3 100644 --- a/iceoryx2/src/service/builder/request_response.rs +++ b/iceoryx2/src/service/builder/request_response.rs @@ -13,6 +13,15 @@ use core::fmt::Debug; use core::marker::PhantomData; +use alloc::format; + +use iceoryx2_bb_elementary::alignment::Alignment; +use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; +use iceoryx2_bb_log::{fail, fatal_panic, warn}; +use iceoryx2_cal::dynamic_storage::{DynamicStorageCreateError, DynamicStorageOpenError}; +use iceoryx2_cal::serialize::Serialize; +use iceoryx2_cal::static_storage::{StaticStorage, StaticStorageCreateError, StaticStorageLocked}; + use crate::prelude::{AttributeSpecifier, AttributeVerifier}; use crate::service::builder::OpenDynamicStorageFailure; use crate::service::dynamic_config::request_response::DynamicConfigSettings; @@ -22,12 +31,6 @@ use crate::service::static_config::message_type_details::TypeDetail; use crate::service::static_config::messaging_pattern::MessagingPattern; use crate::service::{self, header, static_config, NoResource}; use crate::service::{builder, dynamic_config, Service}; -use iceoryx2_bb_elementary::alignment::Alignment; -use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; -use iceoryx2_bb_log::{fail, fatal_panic, warn}; -use iceoryx2_cal::dynamic_storage::{DynamicStorageCreateError, DynamicStorageOpenError}; -use iceoryx2_cal::serialize::Serialize; -use iceoryx2_cal::static_storage::{StaticStorage, StaticStorageCreateError, StaticStorageLocked}; use super::message_type_details::{MessageTypeDetails, TypeVariant}; use super::{CustomHeaderMarker, CustomPayloadMarker, ServiceState, RETRY_LIMIT}; diff --git a/iceoryx2/src/service/mod.rs b/iceoryx2/src/service/mod.rs index 40259cee5..c3e6d9654 100644 --- a/iceoryx2/src/service/mod.rs +++ b/iceoryx2/src/service/mod.rs @@ -253,10 +253,15 @@ pub mod ipc_threadsafe; pub(crate) mod config_scheme; pub(crate) mod naming_scheme; -use alloc::sync::Arc; use core::fmt::Debug; use core::time::Duration; +use alloc::format; +use alloc::string::String; +use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; + use crate::config; use crate::constants::MAX_TYPE_NAME_LENGTH; use crate::node::{NodeId, NodeListFailure, NodeState, SharedNode}; diff --git a/iceoryx2/src/service/naming_scheme.rs b/iceoryx2/src/service/naming_scheme.rs index 0afdb75d4..3f2e76c03 100644 --- a/iceoryx2/src/service/naming_scheme.rs +++ b/iceoryx2/src/service/naming_scheme.rs @@ -10,11 +10,14 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::port::port_identifiers::UniqueListenerId; +use alloc::string::ToString; + use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_log::fatal_panic; use iceoryx2_bb_system_types::file_name::FileName; +use crate::port::port_identifiers::UniqueListenerId; + pub(crate) fn event_concept_name(listener_id: &UniqueListenerId) -> FileName { let msg = "The system does not support the required file name length for the listeners event concept name."; let origin = "event_concept_name()"; diff --git a/iceoryx2/src/service/port_factory/client.rs b/iceoryx2/src/service/port_factory/client.rs index b1fe981f8..d8ead3db7 100644 --- a/iceoryx2/src/service/port_factory/client.rs +++ b/iceoryx2/src/service/port_factory/client.rs @@ -29,16 +29,21 @@ //! # } //! ``` -use super::request_response::PortFactory; +use core::fmt::Debug; + +use alloc::format; + +use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; +use iceoryx2_bb_log::fail; +use iceoryx2_cal::shm_allocator::AllocationStrategy; + use crate::{ port::{client::Client, DegradationAction, DegradationCallback}, prelude::UnableToDeliverStrategy, service, }; -use core::fmt::Debug; -use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; -use iceoryx2_bb_log::fail; -use iceoryx2_cal::shm_allocator::AllocationStrategy; + +use super::request_response::PortFactory; /// Defines a failure that can occur when a [`Client`] is created with /// [`crate::service::port_factory::client::PortFactoryClient`]. diff --git a/iceoryx2/src/service/port_factory/publisher.rs b/iceoryx2/src/service/port_factory/publisher.rs index 71e69af4f..31678e90b 100644 --- a/iceoryx2/src/service/port_factory/publisher.rs +++ b/iceoryx2/src/service/port_factory/publisher.rs @@ -56,11 +56,12 @@ use core::fmt::Debug; +use alloc::format; + use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fail; use iceoryx2_cal::shm_allocator::AllocationStrategy; -use super::publish_subscribe::PortFactory; use crate::{ port::{ publisher::{Publisher, PublisherCreateError}, @@ -70,6 +71,8 @@ use crate::{ service, }; +use super::publish_subscribe::PortFactory; + #[derive(Debug)] pub(crate) struct LocalPublisherConfig { pub(crate) max_loaned_samples: usize, diff --git a/iceoryx2/src/service/port_factory/reader.rs b/iceoryx2/src/service/port_factory/reader.rs index 2b351001a..bbea7b4b7 100644 --- a/iceoryx2/src/service/port_factory/reader.rs +++ b/iceoryx2/src/service/port_factory/reader.rs @@ -29,14 +29,18 @@ //! # } //! ``` -use super::blackboard::PortFactory; -use crate::port::reader::{Reader, ReaderCreateError}; -use crate::service; use core::fmt::Debug; use core::hash::Hash; + +use alloc::format; + use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fail; +use super::blackboard::PortFactory; +use crate::port::reader::{Reader, ReaderCreateError}; +use crate::service; + /// Factory to create a new [`Reader`] port/endpoint for /// [`MessagingPattern::Blackboard`](crate::service::messaging_pattern::MessagingPattern::Blackboard) /// based communication. diff --git a/iceoryx2/src/service/port_factory/server.rs b/iceoryx2/src/service/port_factory/server.rs index 0d4486ffc..bc0ef7f4c 100644 --- a/iceoryx2/src/service/port_factory/server.rs +++ b/iceoryx2/src/service/port_factory/server.rs @@ -33,16 +33,21 @@ //! # } //! ``` -use super::request_response::PortFactory; +use core::fmt::Debug; + +use alloc::format; + +use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; +use iceoryx2_bb_log::{fail, warn}; +use iceoryx2_cal::shm_allocator::AllocationStrategy; + use crate::{ port::{server::Server, DegradationAction, DegradationCallback}, prelude::UnableToDeliverStrategy, service, }; -use core::fmt::Debug; -use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; -use iceoryx2_bb_log::{fail, warn}; -use iceoryx2_cal::shm_allocator::AllocationStrategy; + +use super::request_response::PortFactory; #[derive(Debug, Clone, Copy)] pub(crate) struct LocalServerConfig { diff --git a/iceoryx2/src/service/port_factory/subscriber.rs b/iceoryx2/src/service/port_factory/subscriber.rs index 65121ce3c..16d5bded5 100644 --- a/iceoryx2/src/service/port_factory/subscriber.rs +++ b/iceoryx2/src/service/port_factory/subscriber.rs @@ -30,6 +30,8 @@ use core::fmt::Debug; +use alloc::format; + use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fail; diff --git a/iceoryx2/src/service/port_factory/writer.rs b/iceoryx2/src/service/port_factory/writer.rs index eec76aa5f..518cd83ee 100644 --- a/iceoryx2/src/service/port_factory/writer.rs +++ b/iceoryx2/src/service/port_factory/writer.rs @@ -29,14 +29,18 @@ //! # } //! ``` -use super::blackboard::PortFactory; -use crate::port::writer::{Writer, WriterCreateError}; -use crate::service; use core::fmt::Debug; use core::hash::Hash; + +use alloc::format; + use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fail; +use super::blackboard::PortFactory; +use crate::port::writer::{Writer, WriterCreateError}; +use crate::service; + /// Factory to create a new [`Writer`] port/endpoint for /// [`MessagingPattern::Blackboard`](crate::service::messaging_pattern::MessagingPattern::Blackboard) /// based communication. diff --git a/iceoryx2/src/service/service_id.rs b/iceoryx2/src/service/service_id.rs index 06ac52ae9..bdd223334 100644 --- a/iceoryx2/src/service/service_id.rs +++ b/iceoryx2/src/service/service_id.rs @@ -10,12 +10,15 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::string::ToString; + use iceoryx2_bb_container::semantic_string::*; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fatal_panic; use iceoryx2_bb_system_types::file_name::RestrictedFileName; use iceoryx2_cal::hash::Hash; + use serde::{Deserialize, Serialize}; use super::{messaging_pattern::MessagingPattern, service_name::ServiceName}; diff --git a/iceoryx2/src/service/service_name.rs b/iceoryx2/src/service/service_name.rs index 55be1af83..3920440c4 100644 --- a/iceoryx2/src/service/service_name.rs +++ b/iceoryx2/src/service/service_name.rs @@ -22,13 +22,17 @@ //! # } //! ``` -use crate::constants::MAX_SERVICE_NAME_LENGTH; +use alloc::borrow::ToOwned; +use alloc::format; + use iceoryx2_bb_container::string::*; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use serde::{de::Visitor, Deserialize, Serialize}; +use crate::constants::MAX_SERVICE_NAME_LENGTH; + /// Prefix used to identify internal iceoryx2 services. /// /// This prefix is used to distinguish between user-defined services and internal diff --git a/iceoryx2/src/service/stale_resource_cleanup.rs b/iceoryx2/src/service/stale_resource_cleanup.rs index 746ce4c1c..0d5c7d10e 100644 --- a/iceoryx2/src/service/stale_resource_cleanup.rs +++ b/iceoryx2/src/service/stale_resource_cleanup.rs @@ -10,6 +10,9 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; +use alloc::vec::Vec; + use iceoryx2_bb_log::fail; use iceoryx2_bb_system_types::file_name::FileName; use iceoryx2_cal::event::NamedConceptMgmt; diff --git a/iceoryx2/src/service/static_config/mod.rs b/iceoryx2/src/service/static_config/mod.rs index 842d2e146..d9c99de5c 100644 --- a/iceoryx2/src/service/static_config/mod.rs +++ b/iceoryx2/src/service/static_config/mod.rs @@ -30,10 +30,13 @@ pub mod messaging_pattern; pub mod blackboard; +use alloc::format; + use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_log::fatal_panic; use iceoryx2_cal::hash::Hash; + use serde::{Deserialize, Serialize}; use crate::config; diff --git a/iceoryx2/src/testing.rs b/iceoryx2/src/testing.rs index 9608b2ea9..a2d51c34c 100644 --- a/iceoryx2/src/testing.rs +++ b/iceoryx2/src/testing.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; + use iceoryx2_bb_elementary::math::ToB64; use iceoryx2_bb_posix::unique_system_id::UniqueSystemId; use iceoryx2_bb_posix::{config::TEST_DIRECTORY, testing::*}; diff --git a/iceoryx2/src/waitset.rs b/iceoryx2/src/waitset.rs index 63c786aae..072ac7890 100644 --- a/iceoryx2/src/waitset.rs +++ b/iceoryx2/src/waitset.rs @@ -217,7 +217,9 @@ use core::{ cell::RefCell, fmt::Debug, hash::Hash, marker::PhantomData, sync::atomic::Ordering, time::Duration, }; -use std::collections::HashMap; + +use alloc::vec; +use alloc::vec::Vec; use iceoryx2_bb_elementary::CallbackProgression; use iceoryx2_bb_log::fail; @@ -230,6 +232,8 @@ use iceoryx2_bb_posix::{ use iceoryx2_cal::reactor::*; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicUsize; +use hashbrown::HashMap; + use crate::signal_handling_mode::SignalHandlingMode; /// States why the [`WaitSet::wait_and_process()`] method returned. From 55d5dfd799febfc2e0a107096da90955cfc7a273 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:26:36 +0200 Subject: [PATCH 06/30] [#865] Use iceoryx2_bb_posix::Mutex in iceoryx2 --- iceoryx2/src/node/mod.rs | 66 ++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index 9d4d4de6a..fe90b7287 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -164,6 +164,11 @@ use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend; use iceoryx2_bb_lock_free::mpmc::container::ContainerHandle; use iceoryx2_bb_log::{debug, fail, fatal_panic, trace, warn}; use iceoryx2_bb_posix::clock::{nanosleep, NanosleepError, Time}; +use iceoryx2_bb_posix::mutex::Handle; +use iceoryx2_bb_posix::mutex::Mutex; +use iceoryx2_bb_posix::mutex::MutexBuilder; +use iceoryx2_bb_posix::mutex::MutexHandle; +use iceoryx2_bb_posix::mutex::MutexType; use iceoryx2_bb_posix::process::{Process, ProcessId}; use iceoryx2_bb_posix::signal::SignalHandler; use iceoryx2_bb_posix::unique_system_id::UniqueSystemId; @@ -188,7 +193,6 @@ use crate::signal_handling_mode::SignalHandlingMode; use crate::{config::Config, service::config_scheme::node_details_config}; use hashbrown::HashMap; -use std::sync::Mutex; /// The system-wide unique id of a [`Node`] #[derive( @@ -740,21 +744,29 @@ fn remove_node( #[derive(Debug)] pub(crate) struct RegisteredServices { - data: Mutex>, + handle: MutexHandle>, } unsafe impl Send for RegisteredServices {} unsafe impl Sync for RegisteredServices {} impl RegisteredServices { + pub(crate) fn new() -> Self { + let handle = MutexHandle::new(); + + MutexBuilder::new() + .is_interprocess_capable(false) + .mutex_type(MutexType::Normal) + .create(HashMap::new(), &handle) + .expect("Failed to create mutex"); + + Self { handle } + } + pub(crate) fn add(&self, service_id: &ServiceId, handle: ContainerHandle) { - if self - .data - .lock() - .unwrap() - .insert(*service_id, (handle, 1)) - .is_some() - { + let mut guard = self.mutex().lock().expect("Failed to lock mutex"); + + if guard.insert(*service_id, (handle, 1)).is_some() { fatal_panic!(from "RegisteredServices::add()", "This should never happen! The service with the {:?} was already registered.", service_id); } @@ -765,15 +777,16 @@ impl RegisteredServices { service_id: &ServiceId, mut or_callback: F, ) -> Result<(), OpenDynamicStorageFailure> { - let mut data = self.data.lock().unwrap(); - match data.get_mut(service_id) { - Some(handle) => { - handle.1 += 1; + let mut guard = self.mutex().lock().expect("Failed to lock mutex"); + + match guard.get_mut(service_id) { + Some(entry) => { + entry.1 += 1; } None => { - drop(data); - let handle = or_callback()?; - self.add(service_id, handle); + drop(guard); + let new_handle = or_callback()?; + self.add(service_id, new_handle); } }; Ok(()) @@ -784,18 +797,27 @@ impl RegisteredServices { service_id: &ServiceId, mut cleanup_call: F, ) { - let mut data = self.data.lock().unwrap(); - if let Some(entry) = data.get_mut(service_id) { + let mut guard = self.mutex().lock().expect("Failed to lock mutex"); + + if let Some(entry) = guard.get_mut(service_id) { entry.1 -= 1; if entry.1 == 0 { - cleanup_call(entry.0); - data.remove(service_id); + let handle = entry.0; + guard.remove(service_id); + drop(guard); + cleanup_call(handle); } } else { fatal_panic!(from "RegisteredServices::remove()", "This should never happen! The service with the {:?} was not registered.", service_id); } } + + fn mutex(&self) -> Mutex<'_, '_, HashMap> { + // Safe - the mutex is initialized when constructing the struct and + // not interacted with by anything else. + unsafe { Mutex::from_handle(&self.handle) } + } } #[derive(Debug)] @@ -1276,9 +1298,7 @@ impl NodeBuilder { shared: Arc::new(SharedNode { id: NodeId(node_id), monitoring_token: UnsafeCell::new(Some(monitoring_token)), - registered_services: RegisteredServices { - data: Mutex::new(HashMap::new()), - }, + registered_services: RegisteredServices::new(), _details_storage: details_storage, signal_handling_mode: self.signal_handling_mode, details, From 9d72333c3b6b7fa5fa528242498cc8895a7ca857 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:27:28 +0200 Subject: [PATCH 07/30] [#865] Use core and alloc in iceoryx2-ffi-c --- iceoryx2-ffi/c/Cargo.toml | 6 +++++ iceoryx2-ffi/c/src/api/log.rs | 23 +++++++++++++++---- .../c/src/api/service_builder_blackboard.rs | 23 +++++++++++-------- .../api/service_builder_request_response.rs | 2 ++ .../c/src/api/waitset_attachment_id.rs | 5 ++-- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/iceoryx2-ffi/c/Cargo.toml b/iceoryx2-ffi/c/Cargo.toml index b0479897a..1d276883e 100644 --- a/iceoryx2-ffi/c/Cargo.toml +++ b/iceoryx2-ffi/c/Cargo.toml @@ -18,6 +18,12 @@ build = "build.rs" path = "src/lib.rs" crate-type = ["rlib", "cdylib", "staticlib"] # without "rlib" the doc examples are not run +[features] +default = ["std"] +std = [ + "iceoryx2/std", +] + [build-dependencies] cbindgen = { workspace = true } diff --git a/iceoryx2-ffi/c/src/api/log.rs b/iceoryx2-ffi/c/src/api/log.rs index 446875936..c2dc0c573 100644 --- a/iceoryx2-ffi/c/src/api/log.rs +++ b/iceoryx2-ffi/c/src/api/log.rs @@ -15,14 +15,15 @@ // BEGIN type definition +use core::ffi::{c_char, CStr}; + +use alloc::string::ToString; + use iceoryx2_bb_log::{ - get_log_level, set_log_level, set_log_level_from_env_or, set_log_level_from_env_or_default, - set_logger, Log, LogLevel, __internal_print_log_msg, - logger::{use_console_logger, use_file_logger}, + get_log_level, set_log_level, set_logger, Log, LogLevel, __internal_print_log_msg, }; -use core::ffi::{c_char, CStr}; -use std::sync::Once; +use iceoryx2_pal_concurrency_sync::once::Once; #[repr(C)] #[derive(Copy, Clone)] @@ -150,8 +151,11 @@ pub unsafe extern "C" fn iox2_log( } /// Sets the console logger as default logger. Returns true if the logger was set, otherwise false. +#[cfg(feature = "std")] #[no_mangle] pub extern "C" fn iox2_use_console_logger() -> bool { + use iceoryx2_bb_log::logger::use_console_logger; + use_console_logger() } @@ -160,8 +164,11 @@ pub extern "C" fn iox2_use_console_logger() -> bool { /// # Safety /// /// * log_file must be a valid pointer to a string +#[cfg(feature = "std")] #[no_mangle] pub unsafe extern "C" fn iox2_use_file_logger(log_file: *const c_char) -> bool { + use iceoryx2_bb_log::logger::use_file_logger; + debug_assert!(!log_file.is_null()); let log_file = CStr::from_ptr(log_file).to_string_lossy(); @@ -169,14 +176,20 @@ pub unsafe extern "C" fn iox2_use_file_logger(log_file: *const c_char) -> bool { } /// Sets the log level from environment variable or defaults it if variable does not exist +#[cfg(feature = "std")] #[no_mangle] pub unsafe extern "C" fn iox2_set_log_level_from_env_or_default() { + use iceoryx2_bb_log::set_log_level_from_env_or_default; + set_log_level_from_env_or_default(); } /// Sets the log level from environment variable or to a user given value if variable does not exist +#[cfg(feature = "std")] #[no_mangle] pub unsafe extern "C" fn iox2_set_log_level_from_env_or(v: iox2_log_level_e) { + use iceoryx2_bb_log::set_log_level_from_env_or; + set_log_level_from_env_or(v.into()); } diff --git a/iceoryx2-ffi/c/src/api/service_builder_blackboard.rs b/iceoryx2-ffi/c/src/api/service_builder_blackboard.rs index a4dfc9369..ec7147d52 100644 --- a/iceoryx2-ffi/c/src/api/service_builder_blackboard.rs +++ b/iceoryx2-ffi/c/src/api/service_builder_blackboard.rs @@ -12,17 +12,11 @@ #![allow(non_camel_case_types)] -use super::{iox2_attribute_specifier_h_ref, iox2_attribute_verifier_h_ref, iox2_type_variant_e}; -use crate::api::{ - c_size_t, iox2_port_factory_blackboard_h, iox2_port_factory_blackboard_t, - iox2_service_builder_blackboard_creator_h, iox2_service_builder_blackboard_creator_h_ref, - iox2_service_builder_blackboard_opener_h, iox2_service_builder_blackboard_opener_h_ref, - iox2_service_type_e, AssertNonNullHandle, HandleToType, IntoCInt, KeyFfi, - PortFactoryBlackboardUnion, ServiceBuilderUnion, IOX2_OK, -}; -use crate::create_type_details; use core::ffi::{c_char, c_int, c_void}; use core::mem::ManuallyDrop; + +use alloc::boxed::Box; + use iceoryx2::constants::MAX_BLACKBOARD_KEY_SIZE; use iceoryx2::service::builder::blackboard::{ BlackboardCreateError, BlackboardOpenError, Creator, KeyMemory, Opener, @@ -32,6 +26,17 @@ use iceoryx2::service::static_config::message_type_details::{TypeDetail, TypeNam use iceoryx2_bb_elementary_traits::AsCStr; use iceoryx2_ffi_macros::CStrRepr; +use crate::api::{ + c_size_t, iox2_port_factory_blackboard_h, iox2_port_factory_blackboard_t, + iox2_service_builder_blackboard_creator_h, iox2_service_builder_blackboard_creator_h_ref, + iox2_service_builder_blackboard_opener_h, iox2_service_builder_blackboard_opener_h_ref, + iox2_service_type_e, AssertNonNullHandle, HandleToType, IntoCInt, KeyFfi, + PortFactoryBlackboardUnion, ServiceBuilderUnion, IOX2_OK, +}; +use crate::create_type_details; + +use super::{iox2_attribute_specifier_h_ref, iox2_attribute_verifier_h_ref, iox2_type_variant_e}; + // BEGIN types definition // Function to release the value_ptr passed to [`iox2_service_builder_blackboard_creator_add`] diff --git a/iceoryx2-ffi/c/src/api/service_builder_request_response.rs b/iceoryx2-ffi/c/src/api/service_builder_request_response.rs index aadd2a6c7..5697ddc13 100644 --- a/iceoryx2-ffi/c/src/api/service_builder_request_response.rs +++ b/iceoryx2-ffi/c/src/api/service_builder_request_response.rs @@ -21,6 +21,8 @@ use core::{ slice, }; +use alloc::string::ToString; + use iceoryx2::service::port_factory::request_response::PortFactory; use iceoryx2::service::static_config::message_type_details::TypeDetail; use iceoryx2::service::{ diff --git a/iceoryx2-ffi/c/src/api/waitset_attachment_id.rs b/iceoryx2-ffi/c/src/api/waitset_attachment_id.rs index 65857c647..2f04beb44 100644 --- a/iceoryx2-ffi/c/src/api/waitset_attachment_id.rs +++ b/iceoryx2-ffi/c/src/api/waitset_attachment_id.rs @@ -12,14 +12,15 @@ #![allow(non_camel_case_types)] -use crate::c_size_t; use core::{ffi::c_char, mem::ManuallyDrop}; +use alloc::format; + use iceoryx2::prelude::WaitSetAttachmentId; use iceoryx2_bb_elementary::static_assert::*; use iceoryx2_ffi_macros::iceoryx2_ffi; -use crate::{iox2_service_type_e, iox2_waitset_guard_h_ref}; +use crate::{c_size_t, iox2_service_type_e, iox2_waitset_guard_h_ref}; use super::{AssertNonNullHandle, HandleToType}; From 3de4e2340552b5d32e4f46dd8441881a00c50d8f Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:28:43 +0200 Subject: [PATCH 08/30] [#865] Use core and alloc in iceoryx2-tunnel --- Cargo.lock | 3 ++- iceoryx2-tunnel/backend/Cargo.toml | 2 +- iceoryx2-tunnel/backend/src/lib.rs | 2 ++ iceoryx2-tunnel/backend/src/traits/testing.rs | 12 +++++---- .../conformance-tests/src/event_discovery.rs | 3 ++- .../src/event_propagation.rs | 18 ++++++++----- .../src/publish_subscribe_discovery.rs | 3 ++- .../src/publish_subscribe_propagation.rs | 12 ++++++--- .../end-to-end-tests/ping-pong/src/pinger.rs | 25 +++++++++++++------ .../end-to-end-tests/ping-pong/src/ponger.rs | 13 +++++++--- iceoryx2-tunnel/tunnel/Cargo.toml | 2 ++ iceoryx2-tunnel/tunnel/src/lib.rs | 2 ++ iceoryx2-tunnel/tunnel/src/ports/event.rs | 2 +- iceoryx2-tunnel/tunnel/src/tunnel.rs | 5 +++- 14 files changed, 72 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7cbad4a96..f75d1229a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1706,6 +1706,7 @@ name = "iceoryx2-tunnel" version = "0.7.0" dependencies = [ "generic-tests", + "hashbrown 0.16.0", "iceoryx2", "iceoryx2-bb-log", "iceoryx2-bb-posix", @@ -1719,7 +1720,7 @@ name = "iceoryx2-tunnel-backend" version = "0.7.0" dependencies = [ "iceoryx2", - "iceoryx2-bb-testing", + "iceoryx2-bb-posix", ] [[package]] diff --git a/iceoryx2-tunnel/backend/Cargo.toml b/iceoryx2-tunnel/backend/Cargo.toml index b5fdb2a63..ce3f485de 100644 --- a/iceoryx2-tunnel/backend/Cargo.toml +++ b/iceoryx2-tunnel/backend/Cargo.toml @@ -12,4 +12,4 @@ version = { workspace = true } [dependencies] iceoryx2 = { workspace = true } -iceoryx2-bb-testing = { workspace = true } +iceoryx2-bb-posix = { workspace = true } diff --git a/iceoryx2-tunnel/backend/src/lib.rs b/iceoryx2-tunnel/backend/src/lib.rs index 5c13f2a7a..889e6b10d 100644 --- a/iceoryx2-tunnel/backend/src/lib.rs +++ b/iceoryx2-tunnel/backend/src/lib.rs @@ -10,5 +10,7 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +extern crate alloc; + pub mod traits; pub mod types; diff --git a/iceoryx2-tunnel/backend/src/traits/testing.rs b/iceoryx2-tunnel/backend/src/traits/testing.rs index 1d8fd9129..20a6b2556 100644 --- a/iceoryx2-tunnel/backend/src/traits/testing.rs +++ b/iceoryx2-tunnel/backend/src/traits/testing.rs @@ -12,14 +12,16 @@ use core::time::Duration; -use iceoryx2_bb_testing::test_fail; +use alloc::{format, string::String}; + +use iceoryx2_bb_posix::clock::nanosleep; pub trait Testing { fn sync(_id: String, _timeout: Duration) -> bool { true } - fn retry(mut f: F, period: Duration, max_attempts: Option) + fn retry(mut f: F, period: Duration, max_attempts: Option) -> Result<(), String> where F: FnMut() -> Result<(), &'static str>, { @@ -27,17 +29,17 @@ pub trait Testing { loop { match f() { - Ok(_) => return, + Ok(_) => return Ok(()), Err(failure) => { if let Some(max_attempts) = max_attempts { if attempt >= max_attempts { - test_fail!("{} after {} attempts", failure, attempt); + return Err(format!("{} after {} attempts", failure, attempt)); } } } } - std::thread::sleep(period); + nanosleep(period).unwrap(); attempt += 1; } } diff --git a/iceoryx2-tunnel/conformance-tests/src/event_discovery.rs b/iceoryx2-tunnel/conformance-tests/src/event_discovery.rs index fa873ca4e..d00a7e940 100644 --- a/iceoryx2-tunnel/conformance-tests/src/event_discovery.rs +++ b/iceoryx2-tunnel/conformance-tests/src/event_discovery.rs @@ -161,7 +161,8 @@ pub mod event_discovery { }, TIME_BETWEEN_RETRIES, Some(MAX_RETRIES), - ); + ) + .unwrap(); assert_that!(tunnel_a.tunneled_services().len(), eq 1); assert_that!(tunnel_a.tunneled_services().contains(service_b.service_id()), eq true); diff --git a/iceoryx2-tunnel/conformance-tests/src/event_propagation.rs b/iceoryx2-tunnel/conformance-tests/src/event_propagation.rs index 10e489fb2..1464df4fb 100644 --- a/iceoryx2-tunnel/conformance-tests/src/event_propagation.rs +++ b/iceoryx2-tunnel/conformance-tests/src/event_propagation.rs @@ -85,7 +85,8 @@ pub mod event_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); T::sync(service_a.service_id().as_str().to_string(), TIMEOUT); // Create a listener to connect to the discovered service @@ -119,7 +120,8 @@ pub mod event_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); } } @@ -189,7 +191,8 @@ pub mod event_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); T::sync(service_a.service_id().as_str().to_string(), TIMEOUT); @@ -227,7 +230,8 @@ pub mod event_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); // Propagate a few times to see if there is a loop-back for _ in 0..5 { @@ -298,7 +302,8 @@ pub mod event_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); T::sync(service_a.service_id().as_str().to_string(), TIMEOUT); @@ -360,7 +365,8 @@ pub mod event_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); assert_that!(num_notifications_a, eq 1); assert_that!(num_notifications_b, eq 1); diff --git a/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_discovery.rs b/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_discovery.rs index c4cfde9b7..fc93bd176 100644 --- a/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_discovery.rs +++ b/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_discovery.rs @@ -167,7 +167,8 @@ pub mod publish_subscribe_discovery { }, TIME_BETWEEN_RETRIES, Some(MAX_RETRIES), - ); + ) + .unwrap(); assert_that!(tunnel_a.tunneled_services().len(), eq 1); assert_that!(tunnel_a.tunneled_services().contains(service_b.service_id()), eq true); diff --git a/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_propagation.rs b/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_propagation.rs index 8b04ffb4a..3efd39660 100644 --- a/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_propagation.rs +++ b/iceoryx2-tunnel/conformance-tests/src/publish_subscribe_propagation.rs @@ -93,7 +93,8 @@ pub mod publish_subscribe_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); T::sync(service_a.service_id().as_str().to_string(), TIMEOUT); // Create a subscribe to connect to the tunneled service @@ -144,7 +145,8 @@ pub mod publish_subscribe_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); } } @@ -201,7 +203,8 @@ pub mod publish_subscribe_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); T::sync(service_a.service_id().as_str().to_string(), TIMEOUT); // Create a subscribe to connect to the tunneled service @@ -253,7 +256,8 @@ pub mod publish_subscribe_propagation { }, TIMEOUT, Some(MAX_ATTEMPTS), - ); + ) + .unwrap(); } } diff --git a/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/pinger.rs b/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/pinger.rs index 79871da5f..b3d14db2b 100644 --- a/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/pinger.rs +++ b/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/pinger.rs @@ -10,11 +10,18 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use std::alloc::Layout; -use std::mem::MaybeUninit; -use std::rc::Rc; +use core::alloc::Layout; +use core::mem::size_of; +use core::mem::MaybeUninit; +use core::ptr::copy_nonoverlapping; + +extern crate alloc; +use alloc::alloc::alloc; +use alloc::alloc::dealloc; +use alloc::boxed::Box; +use alloc::format; +use alloc::rc::Rc; -use clap::Parser; use iceoryx2::prelude::{ ipc, set_log_level_from_env_or, LogLevel, NodeBuilder, WaitSetAttachmentId, WaitSetBuilder, }; @@ -24,6 +31,8 @@ use iceoryx2_tunnel_end_to_end_tests::config::*; use iceoryx2_tunnel_end_to_end_tests::payload::*; use iceoryx2_tunnel_end_to_end_tests::testing::*; +use clap::Parser; + fn run_pinger() -> Result<(), Box> { let node = NodeBuilder::new().create::()?; @@ -66,7 +75,7 @@ fn run_pinger() -> Result<(), Box> { let timeout_id = WaitSetAttachmentId::from_guard(&timeout_guard); // Create the payload on the heap - let ptr = unsafe { std::alloc::alloc(Layout::new::>()) } + let ptr = unsafe { alloc(Layout::new::>()) } as *mut MaybeUninit; unsafe { P::write_payload(ptr.cast()); @@ -110,10 +119,10 @@ fn run_pinger() -> Result<(), Box> { // The bytes of the payload are copied directly into shared memory, by-passing stack unsafe { - std::ptr::copy_nonoverlapping( + copy_nonoverlapping( *payload as *const u8, ping_sample.payload_mut().as_mut_ptr().cast(), - std::mem::size_of::(), + size_of::(), ); } @@ -123,7 +132,7 @@ fn run_pinger() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - unsafe { std::alloc::dealloc(ptr as *mut u8, Layout::new::>()) }; + unsafe { dealloc(ptr as *mut u8, Layout::new::>()) }; Ok(()) } diff --git a/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/ponger.rs b/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/ponger.rs index 068f78eba..e11833a70 100644 --- a/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/ponger.rs +++ b/iceoryx2-tunnel/end-to-end-tests/ping-pong/src/ponger.rs @@ -10,7 +10,12 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use clap::Parser; +use core::mem::size_of; +use core::ptr::copy_nonoverlapping; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::{ ipc, set_log_level_from_env_or, CallbackProgression, LogLevel, NodeBuilder, WaitSetAttachmentId, WaitSetBuilder, @@ -20,6 +25,8 @@ use iceoryx2_tunnel_end_to_end_tests::cli::*; use iceoryx2_tunnel_end_to_end_tests::config::*; use iceoryx2_tunnel_end_to_end_tests::payload::*; +use clap::Parser; + fn run_ponger() -> Result<(), Box> { let node = NodeBuilder::new().create::()?; @@ -66,10 +73,10 @@ fn run_ponger() -> Result<(), Box> { // Copy the received ping payload directly into the pong payload, by-passing stack unsafe { - std::ptr::copy_nonoverlapping( + copy_nonoverlapping( ping_sample.payload() as *const P::PayloadType as *const u8, pong_sample.payload_mut().as_mut_ptr().cast(), - std::mem::size_of::(), + size_of::(), ); } diff --git a/iceoryx2-tunnel/tunnel/Cargo.toml b/iceoryx2-tunnel/tunnel/Cargo.toml index e61de1f99..3a78355d1 100644 --- a/iceoryx2-tunnel/tunnel/Cargo.toml +++ b/iceoryx2-tunnel/tunnel/Cargo.toml @@ -21,6 +21,8 @@ iceoryx2-bb-log = { workspace = true } iceoryx2-tunnel-backend = { workspace = true } iceoryx2-services-discovery = { workspace = true } +hashbrown = { workspace = true } + [dev-dependencies] iceoryx2-bb-testing = { workspace = true } generic-tests = { workspace = true } diff --git a/iceoryx2-tunnel/tunnel/src/lib.rs b/iceoryx2-tunnel/tunnel/src/lib.rs index 86280067d..f721e5eca 100644 --- a/iceoryx2-tunnel/tunnel/src/lib.rs +++ b/iceoryx2-tunnel/tunnel/src/lib.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +extern crate alloc; + mod discovery; mod ports; mod tunnel; diff --git a/iceoryx2-tunnel/tunnel/src/ports/event.rs b/iceoryx2-tunnel/tunnel/src/ports/event.rs index 8c44ef9a8..6b819d346 100644 --- a/iceoryx2-tunnel/tunnel/src/ports/event.rs +++ b/iceoryx2-tunnel/tunnel/src/ports/event.rs @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use std::collections::HashSet; +use hashbrown::HashSet; use iceoryx2::{ node::Node, diff --git a/iceoryx2-tunnel/tunnel/src/tunnel.rs b/iceoryx2-tunnel/tunnel/src/tunnel.rs index aaa9497a7..f52cc1ab8 100644 --- a/iceoryx2-tunnel/tunnel/src/tunnel.rs +++ b/iceoryx2-tunnel/tunnel/src/tunnel.rs @@ -11,7 +11,8 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::fmt::Debug; -use std::collections::{HashMap, HashSet}; + +use alloc::string::String; use iceoryx2::node::{Node, NodeBuilder, NodeId}; use iceoryx2::service::service_id::ServiceId; @@ -24,6 +25,8 @@ use iceoryx2_tunnel_backend::traits::{ }; use iceoryx2_tunnel_backend::types::publish_subscribe::LoanFn; +use hashbrown::{HashMap, HashSet}; + use crate::discovery; use crate::ports::event::EventPorts; use crate::ports::publish_subscribe::PublishSubscribePorts; From 7cbf49873c85422e6ec51edfbfd595d49ad829d1 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:29:40 +0200 Subject: [PATCH 09/30] [#865] Use core and alloc in iceoryx2-services-discovery --- Cargo.lock | 1 + iceoryx2-services/discovery/Cargo.toml | 1 + iceoryx2-services/discovery/src/lib.rs | 2 ++ .../discovery/src/service_discovery/tracker.rs | 6 ++++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f75d1229a..1bdf0b984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1691,6 +1691,7 @@ name = "iceoryx2-services-discovery" version = "0.7.0" dependencies = [ "generic-tests", + "hashbrown 0.16.0", "iceoryx2", "iceoryx2-bb-elementary", "iceoryx2-bb-elementary-traits", diff --git a/iceoryx2-services/discovery/Cargo.toml b/iceoryx2-services/discovery/Cargo.toml index f9d7bfc70..0718f1b67 100644 --- a/iceoryx2-services/discovery/Cargo.toml +++ b/iceoryx2-services/discovery/Cargo.toml @@ -21,6 +21,7 @@ iceoryx2-bb-elementary = { workspace = true } iceoryx2-bb-elementary-traits = { workspace = true } once_cell = { workspace = true } serde = { workspace = true } +hashbrown = { workspace = true } [dev-dependencies] iceoryx2-bb-testing = { workspace = true } diff --git a/iceoryx2-services/discovery/src/lib.rs b/iceoryx2-services/discovery/src/lib.rs index b9f623196..059bd8d2b 100644 --- a/iceoryx2-services/discovery/src/lib.rs +++ b/iceoryx2-services/discovery/src/lib.rs @@ -19,5 +19,7 @@ #![warn(missing_docs)] +extern crate alloc; + /// Discovery and tracking of services in an iceoryx2 system pub mod service_discovery; diff --git a/iceoryx2-services/discovery/src/service_discovery/tracker.rs b/iceoryx2-services/discovery/src/service_discovery/tracker.rs index 33ea16c59..d592939c7 100644 --- a/iceoryx2-services/discovery/src/service_discovery/tracker.rs +++ b/iceoryx2-services/discovery/src/service_discovery/tracker.rs @@ -10,12 +10,14 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::vec::Vec; + +use hashbrown::{hash_map::Entry, HashMap, HashSet}; use iceoryx2::{ config::Config, prelude::CallbackProgression, service::{service_id::ServiceId, Service, ServiceDetails, ServiceListError}, }; -use std::collections::{hash_map::Entry, HashMap, HashSet}; /// Errors that can occur during service synchronization. #[derive(Debug, Eq, PartialEq, Clone, Copy)] @@ -28,7 +30,7 @@ pub enum SyncError { } impl core::fmt::Display for SyncError { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "SyncError::{self:?}") } } From 408d66c2ae5f17d6f122340084188c78a00ef8ce Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 03:30:30 +0200 Subject: [PATCH 10/30] [#865] Use core and alloc in iceoryx2-userland-record-and-replay --- .../record-and-replay/src/hex_conversion.rs | 7 +++++-- iceoryx2-userland/record-and-replay/src/lib.rs | 2 ++ iceoryx2-userland/record-and-replay/src/record.rs | 9 ++++++++- iceoryx2-userland/record-and-replay/src/recorder.rs | 2 ++ iceoryx2-userland/record-and-replay/src/replayer.rs | 4 ++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/iceoryx2-userland/record-and-replay/src/hex_conversion.rs b/iceoryx2-userland/record-and-replay/src/hex_conversion.rs index e6f262886..5c4c27aa5 100644 --- a/iceoryx2-userland/record-and-replay/src/hex_conversion.rs +++ b/iceoryx2-userland/record-and-replay/src/hex_conversion.rs @@ -10,6 +10,11 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use core::fmt::Write; + +use alloc::string::String; +use alloc::vec::Vec; + use iceoryx2_bb_log::debug; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -46,8 +51,6 @@ pub fn hex_string_to_bytes(hex_string: &str) -> Result, HexToBytesConver /// Converts bytes into a hex string. Can be converted back with [`hex_string_to_bytes()`]. pub fn bytes_to_hex_string(raw_data: &[u8]) -> String { - use std::fmt::Write; - let mut ret_val = String::with_capacity(3 * raw_data.len()); for byte in raw_data { let _ = write!(&mut ret_val, "{byte:0>2x} "); diff --git a/iceoryx2-userland/record-and-replay/src/lib.rs b/iceoryx2-userland/record-and-replay/src/lib.rs index daa5c9297..f4ff6eb04 100644 --- a/iceoryx2-userland/record-and-replay/src/lib.rs +++ b/iceoryx2-userland/record-and-replay/src/lib.rs @@ -120,6 +120,8 @@ //! # } //! ``` +extern crate alloc; + /// Free functions to convert bytes to a hex string and back. pub mod hex_conversion; diff --git a/iceoryx2-userland/record-and-replay/src/record.rs b/iceoryx2-userland/record-and-replay/src/record.rs index 2a281f149..719426217 100644 --- a/iceoryx2-userland/record-and-replay/src/record.rs +++ b/iceoryx2-userland/record-and-replay/src/record.rs @@ -10,12 +10,19 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use anyhow::Result; use core::time::Duration; + +use alloc::format; +use alloc::string::String; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2::service::static_config::message_type_details::TypeVariant; use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::file::{File, FileReadLineState}; +use anyhow::Result; + use crate::{ hex_conversion::{bytes_to_hex_string, hex_string_to_bytes}, record_header::RecordHeaderDetails, diff --git a/iceoryx2-userland/record-and-replay/src/recorder.rs b/iceoryx2-userland/record-and-replay/src/recorder.rs index 698fe7d05..61495e247 100644 --- a/iceoryx2-userland/record-and-replay/src/recorder.rs +++ b/iceoryx2-userland/record-and-replay/src/recorder.rs @@ -51,6 +51,8 @@ //! # } //! ``` +use alloc::format; + use iceoryx2::prelude::{MessagingPattern, ServiceName}; use iceoryx2::service::static_config::message_type_details::{TypeDetail, TypeVariant}; use iceoryx2_bb_elementary::package_version::PackageVersion; diff --git a/iceoryx2-userland/record-and-replay/src/replayer.rs b/iceoryx2-userland/record-and-replay/src/replayer.rs index 4f849f517..f3a14868b 100644 --- a/iceoryx2-userland/record-and-replay/src/replayer.rs +++ b/iceoryx2-userland/record-and-replay/src/replayer.rs @@ -73,6 +73,10 @@ //! ``` use core::mem::MaybeUninit; + +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::file::AccessMode; use iceoryx2_bb_posix::file::File; From 466b6420e4615f2d9346e1a6a2276e00c4f44a37 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 20:08:17 +0200 Subject: [PATCH 11/30] [#865] Implement core::error::Error for Thread errors --- iceoryx2-bb/posix/src/thread.rs | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/iceoryx2-bb/posix/src/thread.rs b/iceoryx2-bb/posix/src/thread.rs index 3493614d4..8043bf9b5 100644 --- a/iceoryx2-bb/posix/src/thread.rs +++ b/iceoryx2-bb/posix/src/thread.rs @@ -125,23 +125,55 @@ enum_gen! { ThreadSpawnError ThreadSetNameError } +impl core::fmt::Display for ThreadSpawnError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "ThreadSpawnError::{self:?}") + } +} + +impl core::error::Error for ThreadSpawnError {} + #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] pub enum ThreadSignalError { ThreadNoLongerActive, UnknownError(i32), } +impl core::fmt::Display for ThreadSignalError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "ThreadSignalError::{self:?}") + } +} + +impl core::error::Error for ThreadSignalError {} + enum_gen! { ThreadSetNameError entry: UnknownError(i32) } +impl core::fmt::Display for ThreadSetNameError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "ThreadSetNameError::{self:?}") + } +} + +impl core::error::Error for ThreadSetNameError {} + #[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)] pub enum ThreadSetAffinityError { InvalidCpuCores, UnknownError(i32), } +impl core::fmt::Display for ThreadSetAffinityError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "ThreadSetAffinityError::{self:?}") + } +} + +impl core::error::Error for ThreadSetAffinityError {} + enum_gen! { ThreadGetNameError entry: @@ -149,6 +181,14 @@ enum_gen! { UnknownError(i32) } +impl core::fmt::Display for ThreadGetNameError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "ThreadGetNameError::{self:?}") + } +} + +impl core::error::Error for ThreadGetNameError {} + enum_gen! { /// The ThreadError enum is a generalization when one doesn't require the fine-grained error /// handling enums. One can forward ThreadError as more generic return value when a method From 6050a93b83e905ab4fbc358f0918622e2cc5a013 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 20:39:30 +0200 Subject: [PATCH 12/30] [#865] Use core and alloc in examples --- Cargo.lock | 2 ++ examples/Cargo.toml | 3 ++ examples/rust/blackboard/creator.rs | 14 +++++--- examples/rust/blackboard/opener.rs | 13 +++++--- .../creator.rs | 13 +++++--- .../opener.rs | 9 +++-- .../complex_data_types/complex_data_types.rs | 8 +++-- .../publisher.rs | 9 +++-- .../subscriber.rs | 11 +++++-- .../publisher.rs | 11 +++++-- .../subscriber.rs | 11 +++++-- .../publisher.rs | 9 +++-- .../subscriber.rs | 11 +++++-- examples/rust/discovery/discovery.rs | 6 +++- .../discovery_service/discovery_service.rs | 14 +++++--- .../discovery_service_client.rs | 12 ++++--- examples/rust/domains/discovery.rs | 13 +++++--- examples/rust/domains/publisher.rs | 18 ++++++---- examples/rust/domains/subscriber.rs | 20 +++++++---- examples/rust/event/listener.rs | 11 +++++-- examples/rust/event/notifier.rs | 6 ++-- .../event_based_communication/publisher.rs | 15 ++++++--- .../event_based_communication/subscriber.rs | 20 ++++++----- examples/rust/event_multiplexing/notifier.rs | 12 +++++-- examples/rust/event_multiplexing/wait.rs | 22 ++++++++----- .../rust/health_monitoring/central_daemon.rs | 12 +++++-- .../rust/health_monitoring/publisher_1.rs | 9 +++-- .../rust/health_monitoring/publisher_2.rs | 9 +++-- examples/rust/health_monitoring/subscriber.rs | 21 +++++++----- examples/rust/publish_subscribe/publisher.rs | 9 +++-- examples/rust/publish_subscribe/subscriber.rs | 11 +++++-- .../publisher.rs | 9 +++-- .../subscriber.rs | 11 +++++-- .../publisher.rs | 9 +++-- .../subscriber.rs | 11 +++++-- examples/rust/request_response/client.rs | 13 +++++--- examples/rust/request_response/server.rs | 15 ++++++--- .../request_response_dynamic_data/client.rs | 11 +++++-- .../request_response_dynamic_data/server.rs | 13 +++++--- examples/rust/service_attributes/creator.rs | 9 +++-- .../rust/service_attributes/incompatible.rs | 8 +++-- examples/rust/service_attributes/opener.rs | 11 +++++-- examples/rust/service_types/ipc_publisher.rs | 9 +++-- .../ipc_threadsafe_subscriber.rs | 33 +++++++++++-------- examples/rust/service_types/local_pubsub.rs | 21 ++++++++---- 45 files changed, 381 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1bdf0b984..a88f34eb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -927,12 +927,14 @@ name = "example" version = "0.7.0" dependencies = [ "clap", + "hashbrown 0.16.0", "iceoryx2", "iceoryx2-bb-container", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", "iceoryx2-bb-elementary-traits", "iceoryx2-bb-log", + "iceoryx2-bb-posix", "iceoryx2-bb-system-types", "iceoryx2-services-discovery", ] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index abd84fc94..a35ccd2b3 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -19,6 +19,9 @@ iceoryx2-bb-elementary = { workspace = true } iceoryx2-bb-elementary-traits = { workspace = true } iceoryx2-bb-log = { workspace = true } iceoryx2-bb-system-types = { workspace = true } +iceoryx2-bb-posix = { workspace = true } + +hashbrown = { workspace = true } [dev-dependencies] clap = { workspace = true } diff --git a/examples/rust/blackboard/creator.rs b/examples/rust/blackboard/creator.rs index 5b15617b9..5b8a7e8be 100644 --- a/examples/rust/blackboard/creator.rs +++ b/examples/rust/blackboard/creator.rs @@ -11,8 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; +use alloc::format; + use examples_common::BlackboardKey; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -30,7 +36,7 @@ fn main() -> Result<(), Box> { .add::(key_1, INITIAL_VALUE_1) .create()?; - println!("Blackboard created.\n"); + info!("Blackboard created.\n"); let writer = service.writer_builder().create()?; @@ -43,16 +49,16 @@ fn main() -> Result<(), Box> { counter += 1; entry_handle_mut_0.update_with_copy(counter); - println!("Write new value for key 0: {counter}"); + info!("Write new value for key 0: {counter}"); let entry_value_uninit = entry_handle_mut_1.loan_uninit(); let value = INITIAL_VALUE_1 * counter as f64; let entry_value = entry_value_uninit.write(value); entry_handle_mut_1 = entry_value.update(); - println!("Write new value for key 1: {}\n", value); + info!("Write new value for key 1: {}\n", value); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/blackboard/opener.rs b/examples/rust/blackboard/opener.rs index 8e3e3eaa5..3521c347e 100644 --- a/examples/rust/blackboard/opener.rs +++ b/examples/rust/blackboard/opener.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::BlackboardKey; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -33,13 +38,13 @@ fn main() -> Result<(), Box> { let entry_handle_1 = reader.entry::(&key_1)?; while node.wait(CYCLE_TIME).is_ok() { - println!("read values:"); + info!("read values:"); - println!("key: 0, value: {}", entry_handle_0.get()); - println!("key: 1, value: {}\n", entry_handle_1.get()); + info!("key: 0, value: {}", entry_handle_0.get()); + info!("key: 1, value: {}\n", entry_handle_1.get()); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/blackboard_event_based_communication/creator.rs b/examples/rust/blackboard_event_based_communication/creator.rs index 1458bd901..966a59abe 100644 --- a/examples/rust/blackboard_event_based_communication/creator.rs +++ b/examples/rust/blackboard_event_based_communication/creator.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -28,7 +33,7 @@ fn main() -> Result<(), Box> { .add_with_default::(INTERESTING_KEY) .create()?; - println!("Blackboard created.\n"); + info!("Blackboard created.\n"); let event_service = node .service_builder(&"My/Funk/ServiceName".try_into()?) @@ -50,17 +55,17 @@ fn main() -> Result<(), Box> { counter += 1; interesting_entry_handle_mut.update_with_copy(counter); notifier.notify_with_custom_event_id(interesting_entry_id)?; - println!( + info!( "Trigger event with entry id {}", interesting_entry_id.as_value() ); entry_handle_mut.update_with_copy(2 * counter); notifier.notify_with_custom_event_id(entry_id)?; - println!("Trigger event with entry id {}", entry_id.as_value()); + info!("Trigger event with entry id {}", entry_id.as_value()); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/blackboard_event_based_communication/opener.rs b/examples/rust/blackboard_event_based_communication/opener.rs index 39fb4bb4d..4961800dc 100644 --- a/examples/rust/blackboard_event_based_communication/opener.rs +++ b/examples/rust/blackboard_event_based_communication/opener.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -39,7 +44,7 @@ fn main() -> Result<(), Box> { while node.wait(Duration::ZERO).is_ok() { if let Ok(Some(id)) = listener.timed_wait_one(CYCLE_TIME) { if id == entry_handle.entry_id() { - println!( + info!( "read: {} for entry id {}", entry_handle.get(), id.as_value() @@ -48,7 +53,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/complex_data_types/complex_data_types.rs b/examples/rust/complex_data_types/complex_data_types.rs index ebd368e03..6a7ec79f6 100644 --- a/examples/rust/complex_data_types/complex_data_types.rs +++ b/examples/rust/complex_data_types/complex_data_types.rs @@ -12,8 +12,12 @@ use core::time::Duration; +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; use iceoryx2_bb_container::{queue::FixedSizeQueue, string::*, vector::*}; +use iceoryx2_bb_log::info; // For both data types we derive from PlacementDefault to allow in memory initialization // without any copy. Avoids stack overflows when data type is larger than the available stack. @@ -79,11 +83,11 @@ fn main() -> Result<(), Box> { .push(StaticString::from_bytes(b"buh")?); sample.send()?; - println!("{counter} :: send"); + info!("{counter} :: send"); // receive sample and print it while let Some(sample) = subscriber.receive()? { - println!( + info!( "{} :: received: {:?}", counter, sample.payload().plain_old_data diff --git a/examples/rust/cross_language_communication_basics/publisher.rs b/examples/rust/cross_language_communication_basics/publisher.rs index c165c088c..aa776014c 100644 --- a/examples/rust/cross_language_communication_basics/publisher.rs +++ b/examples/rust/cross_language_communication_basics/publisher.rs @@ -11,9 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -45,10 +50,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + info!("Send sample {counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_basics/subscriber.rs b/examples/rust/cross_language_communication_basics/subscriber.rs index 3218c7668..dac009bd7 100644 --- a/examples/rust/cross_language_communication_basics/subscriber.rs +++ b/examples/rust/cross_language_communication_basics/subscriber.rs @@ -11,9 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -29,11 +34,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + info!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!( + info!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -41,7 +46,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_complex_types/publisher.rs b/examples/rust/cross_language_communication_complex_types/publisher.rs index 0fd74bd39..64ed914a1 100644 --- a/examples/rust/cross_language_communication_complex_types/publisher.rs +++ b/examples/rust/cross_language_communication_complex_types/publisher.rs @@ -11,12 +11,17 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; +use alloc::str::FromStr; + use examples_common::ComplexType; use examples_common::FullName; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use std::str::FromStr; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -52,10 +57,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + info!("Send sample {counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_complex_types/subscriber.rs b/examples/rust/cross_language_communication_complex_types/subscriber.rs index bd748a86c..2f77db00b 100644 --- a/examples/rust/cross_language_communication_complex_types/subscriber.rs +++ b/examples/rust/cross_language_communication_complex_types/subscriber.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::ComplexType; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -27,15 +32,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + info!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {}", sample.some_matrix[2][5]); + info!("received: {}", sample.some_matrix[2][5]); } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_container/publisher.rs b/examples/rust/cross_language_communication_container/publisher.rs index 18d597022..6f50b2c2d 100644 --- a/examples/rust/cross_language_communication_container/publisher.rs +++ b/examples/rust/cross_language_communication_container/publisher.rs @@ -11,9 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -49,10 +54,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + info!("Send sample {counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_container/subscriber.rs b/examples/rust/cross_language_communication_container/subscriber.rs index 17e7f0c57..77ae5becb 100644 --- a/examples/rust/cross_language_communication_container/subscriber.rs +++ b/examples/rust/cross_language_communication_container/subscriber.rs @@ -11,9 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -34,11 +39,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + info!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!( + info!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -46,7 +51,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/discovery/discovery.rs b/examples/rust/discovery/discovery.rs index 8faf066fb..6d44e97fd 100644 --- a/examples/rust/discovery/discovery.rs +++ b/examples/rust/discovery/discovery.rs @@ -10,12 +10,16 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); ipc::Service::list(Config::global_config(), |service| { - println!("\n{:#?}", &service); + info!("\n{:#?}", &service); CallbackProgression::Continue })?; diff --git a/examples/rust/discovery_service/discovery_service.rs b/examples/rust/discovery_service/discovery_service.rs index f5c77af17..edaaec5e0 100644 --- a/examples/rust/discovery_service/discovery_service.rs +++ b/examples/rust/discovery_service/discovery_service.rs @@ -10,7 +10,11 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::{error, info}; use iceoryx2_services_discovery::*; use service_discovery::Discovery; @@ -24,7 +28,7 @@ fn main() -> Result<(), Box> { .publish_subscribe::() .open() .inspect_err(|_| { - eprintln!("Unable to open service discovery service. Was it started?"); + error!("Unable to open service discovery service. Was it started?"); })?; let subscriber = publish_subscribe.subscriber_builder().create()?; @@ -34,7 +38,7 @@ fn main() -> Result<(), Box> { .event() .open() .inspect_err(|_| { - eprintln!("unable to open service discovery service. Was it started?"); + error!("unable to open service discovery service. Was it started?"); })?; let listener = event.listener_builder().create()?; @@ -42,7 +46,7 @@ fn main() -> Result<(), Box> { let guard = waitset.attach_notification(&listener)?; let attachment = WaitSetAttachmentId::from_guard(&guard); - println!("Discovery service ready!"); + info!("Discovery service ready!"); let on_event = |attachment_id: WaitSetAttachmentId| { if attachment_id == attachment { @@ -53,10 +57,10 @@ fn main() -> Result<(), Box> { while let Ok(Some(sample)) = subscriber.receive() { match sample.payload() { Discovery::Added(details) => { - println!("Added: {:?}", details.name()); + info!("Added: {:?}", details.name()); } Discovery::Removed(details) => { - println!("Removed: {:?}", details.name()); + info!("Removed: {:?}", details.name()); } } } diff --git a/examples/rust/discovery_service/discovery_service_client.rs b/examples/rust/discovery_service/discovery_service_client.rs index c91cda9ab..2f6d83576 100644 --- a/examples/rust/discovery_service/discovery_service_client.rs +++ b/examples/rust/discovery_service/discovery_service_client.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::{prelude::*, service::static_config::StaticConfig}; +use iceoryx2_bb_log::info; use iceoryx2_services_discovery::service_discovery::service_name; const CYCLE_TIME: Duration = Duration::from_millis(10); @@ -36,11 +41,10 @@ fn main() -> Result<(), Box> { if attachment_id.has_event_from(&guard) { while let Some(response) = pending_response.receive().unwrap() { for service in response.payload().iter() { - println!("Service ID: {:?}", service.service_id().as_str()); - println!("Service Name: {:?}", service.name().as_str()); - println!(); + info!("Service ID: {:?}", service.service_id().as_str()); + info!("Service Name: {:?}", service.name().as_str()); } - println!("exit"); + info!("exit"); return CallbackProgression::Stop; } } diff --git a/examples/rust/domains/discovery.rs b/examples/rust/domains/discovery.rs index 5791f4cf2..a7088e309 100644 --- a/examples/rust/domains/discovery.rs +++ b/examples/rust/domains/discovery.rs @@ -10,12 +10,15 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +extern crate alloc; +use alloc::boxed::Box; +use alloc::string::String; + use clap::Parser; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{set_log_level, LogLevel}; +use iceoryx2_bb_log::{info, set_log_level, LogLevel}; fn main() -> Result<(), Box> { - set_log_level_from_env_or(LogLevel::Info); let args = parse_args(); // create a new config based on the global config @@ -25,11 +28,11 @@ fn main() -> Result<(), Box> { // Therefore, different domain names never share the same resources. config.global.prefix = FileName::new(args.domain.as_bytes())?; - println!("\nServices running in domain \"{}\":", args.domain); + info!("\nServices running in domain \"{}\":", args.domain); // use the custom config when listing the services ipc::Service::list(&config, |service| { - println!(" {}", &service.static_details.name()); + info!(" {}", &service.static_details.name()); CallbackProgression::Continue })?; @@ -56,7 +59,7 @@ fn define_log_level(args: &Args) { if args.debug { set_log_level(LogLevel::Trace); } else { - set_log_level(LogLevel::Warn); + set_log_level(LogLevel::Info); } } diff --git a/examples/rust/domains/publisher.rs b/examples/rust/domains/publisher.rs index f924581ef..7478d6f73 100644 --- a/examples/rust/domains/publisher.rs +++ b/examples/rust/domains/publisher.rs @@ -10,16 +10,22 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use clap::Parser; +use core::result::Result; use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; +use alloc::string::String; + +use clap::Parser; + use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{set_log_level, LogLevel}; +use iceoryx2_bb_log::{info, set_log_level, LogLevel}; const CYCLE_TIME: Duration = Duration::from_secs(1); fn main() -> Result<(), Box> { - set_log_level_from_env_or(LogLevel::Info); let args = parse_args(); // create a new config based on the global config @@ -59,13 +65,13 @@ fn main() -> Result<(), Box> { sample.send()?; - println!( + info!( "[domain: \"{}\", service: \"{}\"] Send sample {} ...", args.domain, args.service, counter ); } - println!("exit"); + info!("exit"); Ok(()) } @@ -93,7 +99,7 @@ fn define_log_level(args: &Args) { if args.debug { set_log_level(LogLevel::Trace); } else { - set_log_level(LogLevel::Warn); + set_log_level(LogLevel::Info); } } diff --git a/examples/rust/domains/subscriber.rs b/examples/rust/domains/subscriber.rs index aae742f08..a386b4b2d 100644 --- a/examples/rust/domains/subscriber.rs +++ b/examples/rust/domains/subscriber.rs @@ -10,16 +10,22 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use clap::Parser; +use core::result::Result; use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; +use alloc::string::String; + +use clap::Parser; + use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{set_log_level, LogLevel}; +use iceoryx2_bb_log::{info, set_log_level, LogLevel}; const CYCLE_TIME: Duration = Duration::from_secs(1); fn main() -> Result<(), Box> { - set_log_level_from_env_or(LogLevel::Info); let args = parse_args(); // create a new config based on the global config @@ -42,17 +48,17 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!( + info!( "subscribed to: [domain: \"{}\", service: \"{}\"]", args.domain, args.service ); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {:?}", *sample); + info!("received: {:?}", *sample); } } - println!("exit"); + info!("exit"); Ok(()) } @@ -80,7 +86,7 @@ fn define_log_level(args: &Args) { if args.debug { set_log_level(LogLevel::Trace); } else { - set_log_level(LogLevel::Warn); + set_log_level(LogLevel::Info); } } diff --git a/examples/rust/event/listener.rs b/examples/rust/event/listener.rs index 45069977a..9e5aa4569 100644 --- a/examples/rust/event/listener.rs +++ b/examples/rust/event/listener.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -26,15 +31,15 @@ fn main() -> Result<(), Box> { let listener = event.listener_builder().create()?; - println!("Listener ready to receive events!"); + info!("Listener ready to receive events!"); while node.wait(Duration::ZERO).is_ok() { if let Ok(Some(event_id)) = listener.timed_wait_one(CYCLE_TIME) { - println!("event was triggered with id: {event_id:?}"); + info!("event was triggered with id: {event_id:?}"); } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/event/notifier.rs b/examples/rust/event/notifier.rs index 7a47a4c93..775167354 100644 --- a/examples/rust/event/notifier.rs +++ b/examples/rust/event/notifier.rs @@ -11,7 +11,9 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -32,10 +34,10 @@ fn main() -> Result<(), Box> { counter += 1; notifier.notify_with_custom_event_id(EventId::new(counter % max_event_id))?; - println!("Trigger event with id {counter} ..."); + info!("Trigger event with id {counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/event_based_communication/publisher.rs b/examples/rust/event_based_communication/publisher.rs index db27ab51c..8c9683359 100644 --- a/examples/rust/event_based_communication/publisher.rs +++ b/examples/rust/event_based_communication/publisher.rs @@ -11,6 +11,10 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::{PubSubEvent, TransmissionData}; use iceoryx2::{ port::{ @@ -19,6 +23,7 @@ use iceoryx2::{ }, prelude::*, }; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); const HISTORY_SIZE: usize = 20; @@ -41,7 +46,7 @@ fn main() -> Result<(), Box> { let on_event = |attachment_id: WaitSetAttachmentId| { // when the cyclic trigger guard gets notified we send out a new message if attachment_id.has_event_from(&cyclic_trigger_guard) { - println!("send message: {counter}"); + info!("send message: {counter}"); publisher.send(counter).unwrap(); counter += 1; // when something else happens on the publisher we handle the events @@ -55,7 +60,7 @@ fn main() -> Result<(), Box> { // event callback or an interrupt/termination signal was received. waitset.wait_and_process(on_event)?; - println!("exit"); + info!("exit"); Ok(()) } @@ -112,17 +117,17 @@ impl CustomPublisher { let event: PubSubEvent = event.into(); match event { PubSubEvent::SubscriberConnected => { - println!("new subscriber connected - delivering history"); + info!("new subscriber connected - delivering history"); self.publisher.update_connections().unwrap(); self.notifier .notify_with_custom_event_id(PubSubEvent::SentHistory.into()) .unwrap(); } PubSubEvent::SubscriberDisconnected => { - println!("subscriber disconnected"); + info!("subscriber disconnected"); } PubSubEvent::ReceivedSample => { - println!("subscriber has consumed sample"); + info!("subscriber has consumed sample"); } _ => (), } diff --git a/examples/rust/event_based_communication/subscriber.rs b/examples/rust/event_based_communication/subscriber.rs index 495d5a63b..9e9d6060f 100644 --- a/examples/rust/event_based_communication/subscriber.rs +++ b/examples/rust/event_based_communication/subscriber.rs @@ -12,12 +12,16 @@ use core::time::Duration; +extern crate alloc; +use alloc::boxed::Box; + use examples_common::{PubSubEvent, TransmissionData}; use iceoryx2::{ port::{listener::Listener, notifier::Notifier, subscriber::Subscriber}, prelude::*, sample::Sample, }; +use iceoryx2_bb_log::info; const HISTORY_SIZE: usize = 20; const DEADLINE: Duration = Duration::from_secs(2); @@ -41,9 +45,7 @@ fn main() -> Result<(), Box> { // If the subscriber did not receive an event until DEADLINE has // passed, we print out a warning. } else if attachment_id.has_missed_deadline(&subscriber_guard) { - println!( - "Contract violation! The subscriber did not receive a message for {DEADLINE:?}." - ); + info!("Contract violation! The subscriber did not receive a message for {DEADLINE:?}."); } CallbackProgression::Continue @@ -51,7 +53,7 @@ fn main() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - println!("exit"); + info!("exit"); Ok(()) } @@ -111,18 +113,18 @@ impl CustomSubscriber { let event: PubSubEvent = event.into(); match event { PubSubEvent::SentHistory => { - println!("History delivered"); + info!("History delivered"); while let Ok(Some(sample)) = self.receive() { - println!(" history: {:?}", sample.x); + info!(" history: {:?}", sample.x); } } PubSubEvent::SentSample => { while let Ok(Some(sample)) = self.receive() { - println!("received: {:?}", sample.x); + info!("received: {:?}", sample.x); } } - PubSubEvent::PublisherConnected => println!("new publisher connected"), - PubSubEvent::PublisherDisconnected => println!("publisher disconnected"), + PubSubEvent::PublisherConnected => info!("new publisher connected"), + PubSubEvent::PublisherDisconnected => info!("publisher disconnected"), _ => (), } } diff --git a/examples/rust/event_multiplexing/notifier.rs b/examples/rust/event_multiplexing/notifier.rs index 2e7e5818e..027c71a5c 100644 --- a/examples/rust/event_multiplexing/notifier.rs +++ b/examples/rust/event_multiplexing/notifier.rs @@ -10,9 +10,15 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use clap::Parser; use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; +use alloc::string::String; + +use clap::Parser; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -31,10 +37,10 @@ fn main() -> Result<(), Box> { while node.wait(CYCLE_TIME).is_ok() { notifier.notify_with_custom_event_id(EventId::new(args.event_id))?; - println!("[service: \"{}\"] Trigger event ...", args.service); + info!("[service: \"{}\"] Trigger event ...", args.service); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/event_multiplexing/wait.rs b/examples/rust/event_multiplexing/wait.rs index c814f1cb3..d502e5057 100644 --- a/examples/rust/event_multiplexing/wait.rs +++ b/examples/rust/event_multiplexing/wait.rs @@ -10,9 +10,17 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use clap::Parser; +extern crate alloc; +use alloc::boxed::Box; +use alloc::string::String; +use alloc::vec; +use alloc::vec::Vec; + use iceoryx2::{port::listener::Listener, prelude::*}; -use std::collections::HashMap; +use iceoryx2_bb_log::info; + +use clap::Parser; +use hashbrown::HashMap; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); @@ -51,24 +59,20 @@ fn main() -> Result<(), Box> { guards.push(guard); } - println!("Waiting on the following services: {:?}", args.services); + info!("Waiting on the following services: {:?}", args.services); // the callback that is called when a listener has received an event let on_event = |attachment_id: WaitSetAttachmentId| { if let Some((service_name, listener)) = listener_attachments.get(&attachment_id) { - print!("Received trigger from \"{service_name}\" ::"); - // IMPORTANT: // We need to collect all notifications since the WaitSet will wake us up as long as // there is something to read. If we skip this step completely we will end up in a // busy loop. listener .try_wait_all(|event_id| { - print!(" {event_id:?}"); + info!("Received trigger from \"{service_name}\" :: {event_id:?}"); }) .unwrap(); - - println!(); } CallbackProgression::Continue @@ -79,7 +83,7 @@ fn main() -> Result<(), Box> { // didn't add this to the example so feel free to play around with it. waitset.wait_and_process(on_event)?; - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/central_daemon.rs b/examples/rust/health_monitoring/central_daemon.rs index 3102e7f21..43e5585bd 100644 --- a/examples/rust/health_monitoring/central_daemon.rs +++ b/examples/rust/health_monitoring/central_daemon.rs @@ -11,8 +11,14 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::PubSubEvent; -use iceoryx2::{node::NodeView, prelude::*}; +use iceoryx2::node::NodeView; +use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(100); const DEADLINE_SERVICE_1: Duration = Duration::from_millis(1500); @@ -72,7 +78,7 @@ fn main() -> Result<(), Box> { let waitset = WaitSetBuilder::new().create::()?; let _cycle_guard = waitset.attach_interval(CYCLE_TIME); - println!("Central daemon up and running."); + info!("Central daemon up and running."); waitset.wait_and_process(|_| { // The only task of our central daemon is it to monitor all running nodes and cleanup their // resources if a process has died. @@ -90,7 +96,7 @@ fn main() -> Result<(), Box> { fn find_and_cleanup_dead_nodes() { Node::::list(Config::global_config(), |node_state| { if let NodeState::Dead(state) = node_state { - println!( + info!( "detected dead node: {:?}", state.details().as_ref().map(|v| v.name()) ); diff --git a/examples/rust/health_monitoring/publisher_1.rs b/examples/rust/health_monitoring/publisher_1.rs index daf2e9f73..eff850c8d 100644 --- a/examples/rust/health_monitoring/publisher_1.rs +++ b/examples/rust/health_monitoring/publisher_1.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(1000); @@ -41,7 +46,7 @@ fn main() -> Result<(), Box> { let _cycle_guard = waitset.attach_interval(CYCLE_TIME); waitset.wait_and_process(|_| { - println!("{service_name}: Send sample {counter} ..."); + info!("{service_name}: Send sample {counter} ..."); publisher .send_copy(counter) .expect("sample delivery successful."); @@ -50,7 +55,7 @@ fn main() -> Result<(), Box> { CallbackProgression::Continue })?; - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/publisher_2.rs b/examples/rust/health_monitoring/publisher_2.rs index b983107d1..eb661bc4b 100644 --- a/examples/rust/health_monitoring/publisher_2.rs +++ b/examples/rust/health_monitoring/publisher_2.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(1500); @@ -41,7 +46,7 @@ fn main() -> Result<(), Box> { let _cycle_guard = waitset.attach_interval(CYCLE_TIME); waitset.wait_and_process(|_| { - println!("{service_name}: Send sample {counter} ..."); + info!("{service_name}: Send sample {counter} ..."); publisher .send_copy(counter) .expect("sample delivery successful."); @@ -50,7 +55,7 @@ fn main() -> Result<(), Box> { CallbackProgression::Continue })?; - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/subscriber.rs b/examples/rust/health_monitoring/subscriber.rs index 66e0ce560..9a2f40481 100644 --- a/examples/rust/health_monitoring/subscriber.rs +++ b/examples/rust/health_monitoring/subscriber.rs @@ -11,12 +11,17 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::{open_service, PubSubEvent}; use iceoryx2::{ node::NodeView, port::{listener::Listener, subscriber::Subscriber}, prelude::*, }; +use iceoryx2_bb_log::info; const REACTION_BUFFER_MS: u64 = 500; const CYCLE_TIME_1: Duration = Duration::from_millis(1000 + REACTION_BUFFER_MS); @@ -49,9 +54,7 @@ fn main() -> Result<(), Box> { let listener_2_guard = waitset.attach_deadline(&listener_2, deadline_2)?; let missed_deadline = |service_name, cycle_time| { - println!( - "{service_name}: violated contract and did not send a message after {cycle_time:?}." - ); + info!("{service_name}: violated contract and did not send a message after {cycle_time:?}."); }; let on_event = |attachment_id: WaitSetAttachmentId| { @@ -83,7 +86,7 @@ fn main() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - println!("exit"); + info!("exit"); Ok(()) } @@ -91,7 +94,7 @@ fn main() -> Result<(), Box> { fn find_and_cleanup_dead_nodes() { Node::::list(Config::global_config(), |node_state| { if let NodeState::Dead(state) = node_state { - println!( + info!( "detected dead node: {:?}", state.details().as_ref().map(|v| v.name()) ); @@ -111,14 +114,14 @@ fn handle_incoming_event( listener .try_wait_all(|event_id| { if event_id == PubSubEvent::ProcessDied.into() { - println!("{service_name}: process died!"); + info!("{service_name}: process died!"); } else if event_id == PubSubEvent::PublisherConnected.into() { - println!("{service_name}: publisher connected!"); + info!("{service_name}: publisher connected!"); } else if event_id == PubSubEvent::PublisherDisconnected.into() { - println!("{service_name}: publisher disconnected!"); + info!("{service_name}: publisher disconnected!"); } else if event_id == PubSubEvent::SentSample.into() { if let Some(sample) = subscriber.receive().expect("") { - println!("{}: Received sample {} ...", service_name, *sample) + info!("{}: Received sample {} ...", service_name, *sample) } } }) diff --git a/examples/rust/publish_subscribe/publisher.rs b/examples/rust/publish_subscribe/publisher.rs index 96e04d865..dd8cba070 100644 --- a/examples/rust/publish_subscribe/publisher.rs +++ b/examples/rust/publish_subscribe/publisher.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -41,10 +46,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + info!("Send sample {counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe/subscriber.rs b/examples/rust/publish_subscribe/subscriber.rs index 278461c62..15d134035 100644 --- a/examples/rust/publish_subscribe/subscriber.rs +++ b/examples/rust/publish_subscribe/subscriber.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -27,15 +32,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + info!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {:?}", *sample); + info!("received: {:?}", *sample); } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_dynamic_data/publisher.rs b/examples/rust/publish_subscribe_dynamic_data/publisher.rs index 7530bc877..4d83929e5 100644 --- a/examples/rust/publish_subscribe_dynamic_data/publisher.rs +++ b/examples/rust/publish_subscribe_dynamic_data/publisher.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -45,12 +50,12 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} with {required_memory_size} bytes..."); + info!("Send sample {counter} with {required_memory_size} bytes..."); counter += 1; } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs index 45904efc6..54e0517b9 100644 --- a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs +++ b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -26,15 +31,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + info!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received {} bytes", sample.payload().len()); + info!("received {} bytes", sample.payload().len()); } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_with_user_header/publisher.rs b/examples/rust/publish_subscribe_with_user_header/publisher.rs index a6a1af917..942281b43 100644 --- a/examples/rust/publish_subscribe_with_user_header/publisher.rs +++ b/examples/rust/publish_subscribe_with_user_header/publisher.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::CustomHeader; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -44,10 +49,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + info!("Send sample {counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_with_user_header/subscriber.rs b/examples/rust/publish_subscribe_with_user_header/subscriber.rs index 8483cfa4c..fa999e065 100644 --- a/examples/rust/publish_subscribe_with_user_header/subscriber.rs +++ b/examples/rust/publish_subscribe_with_user_header/subscriber.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::CustomHeader; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -28,11 +33,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + info!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!( + info!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -40,7 +45,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/request_response/client.rs b/examples/rust/request_response/client.rs index 16fb48b5f..4a06b16f5 100644 --- a/examples/rust/request_response/client.rs +++ b/examples/rust/request_response/client.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -31,13 +36,13 @@ fn main() -> Result<(), Box> { let mut response_counter: u64 = 0; // sending first request by using slower, inefficient copy API - println!("send request {request_counter} ..."); + info!("send request {request_counter} ..."); let mut pending_response = client.send_copy(request_counter)?; while node.wait(CYCLE_TIME).is_ok() { // acquire all responses to our request from our buffer that were sent by the servers while let Some(response) = pending_response.receive()? { - println!(" received response {response_counter}: {:?}", *response); + info!(" received response {response_counter}: {:?}", *response); response_counter += 1; } @@ -48,10 +53,10 @@ fn main() -> Result<(), Box> { pending_response = request.send()?; - println!("send request {request_counter} ..."); + info!("send request {request_counter} ..."); } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/request_response/server.rs b/examples/rust/request_response/server.rs index 2d51c7d46..bb38b6313 100644 --- a/examples/rust/request_response/server.rs +++ b/examples/rust/request_response/server.rs @@ -11,8 +11,13 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(100); @@ -27,19 +32,19 @@ fn main() -> Result<(), Box> { let server = service.server_builder().create()?; - println!("Server ready to receive requests!"); + info!("Server ready to receive requests!"); let mut counter = 0; while node.wait(CYCLE_TIME).is_ok() { while let Some(active_request) = server.receive()? { - println!("received request: {:?}", *active_request); + info!("received request: {:?}", *active_request); let response = TransmissionData { x: 5 + counter, y: 6 * counter, funky: 7.77, }; - println!(" send response: {response:?}"); + info!(" send response: {response:?}"); // send first response by using the slower, non-zero-copy API active_request.send_copy(response)?; @@ -51,7 +56,7 @@ fn main() -> Result<(), Box> { y: counter + n as i32, funky: counter as f64 * 0.1234, }); - println!(" send response: {:?}", *response); + info!(" send response: {:?}", *response); response.send()?; } @@ -64,7 +69,7 @@ fn main() -> Result<(), Box> { counter += 1; } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/request_response_dynamic_data/client.rs b/examples/rust/request_response_dynamic_data/client.rs index a9b97a6d5..665d1a3ba 100644 --- a/examples/rust/request_response_dynamic_data/client.rs +++ b/examples/rust/request_response_dynamic_data/client.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -44,7 +49,7 @@ fn main() -> Result<(), Box> { let request = request.write_from_fn(|byte_idx| ((byte_idx + counter) % 255) as u8); let pending_response = request.send()?; - println!("send request {counter} with {required_memory_size} bytes ..."); + info!("send request {counter} with {required_memory_size} bytes ..."); if node.wait(CYCLE_TIME).is_err() { break; @@ -52,7 +57,7 @@ fn main() -> Result<(), Box> { // acquire all responses to our request from our buffer that were sent by the servers while let Some(response) = pending_response.receive()? { - println!( + info!( " received response with {} bytes", response.payload().len() ); @@ -61,7 +66,7 @@ fn main() -> Result<(), Box> { counter += 1; } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/request_response_dynamic_data/server.rs b/examples/rust/request_response_dynamic_data/server.rs index adabe539a..f690baad0 100644 --- a/examples/rust/request_response_dynamic_data/server.rs +++ b/examples/rust/request_response_dynamic_data/server.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(100); @@ -36,12 +41,12 @@ fn main() -> Result<(), Box> { .allocation_strategy(AllocationStrategy::PowerOfTwo) .create()?; - println!("Server ready to receive requests!"); + info!("Server ready to receive requests!"); let mut counter = 1; while node.wait(CYCLE_TIME).is_ok() { while let Some(active_request) = server.receive()? { - println!( + info!( "received request with {} bytes ...", active_request.payload().len() ); @@ -49,14 +54,14 @@ fn main() -> Result<(), Box> { let required_memory_size = 1_000_000.min(counter * counter); let response = active_request.loan_slice_uninit(required_memory_size)?; let response = response.write_from_fn(|byte_idx| ((byte_idx + counter) % 255) as u8); - println!(" send response with {} bytes", response.payload().len()); + info!(" send response with {} bytes", response.payload().len()); response.send()?; } counter += 1; } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/service_attributes/creator.rs b/examples/rust/service_attributes/creator.rs index 98dccd776..731b64075 100644 --- a/examples/rust/service_attributes/creator.rs +++ b/examples/rust/service_attributes/creator.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -37,7 +42,7 @@ fn main() -> Result<(), Box> { let publisher = service.publisher_builder().create()?; - println!("defined service attributes: {:?}", service.attributes()); + info!("defined service attributes: {:?}", service.attributes()); while node.wait(CYCLE_TIME).is_ok() { let sample = publisher.loan_uninit()?; @@ -45,7 +50,7 @@ fn main() -> Result<(), Box> { sample.send()?; } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/service_attributes/incompatible.rs b/examples/rust/service_attributes/incompatible.rs index fc181ed27..d2e1604fb 100644 --- a/examples/rust/service_attributes/incompatible.rs +++ b/examples/rust/service_attributes/incompatible.rs @@ -10,7 +10,11 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); @@ -25,7 +29,7 @@ fn main() -> Result<(), Box> { &AttributeVerifier::new() .require(&"camera_resolution".try_into()?, &"3840x2160".try_into()?)?, ) - .map_err(|e| println!("camera_resolution: 3840x2160 -> {:?}", e)); + .map_err(|e| info!("camera_resolution: 3840x2160 -> {:?}", e)); let _incompatible_service = node .service_builder(&"Service/With/Properties".try_into()?) @@ -34,7 +38,7 @@ fn main() -> Result<(), Box> { // the opening of the service will fail since the key is not defined. &AttributeVerifier::new().require_key(&"camera_type".try_into()?)?, ) - .map_err(|e| println!("camera_type -> {:?}", e)); + .map_err(|e| info!("camera_type -> {:?}", e)); Ok(()) } diff --git a/examples/rust/service_attributes/opener.rs b/examples/rust/service_attributes/opener.rs index c4126c47c..082db9beb 100644 --- a/examples/rust/service_attributes/opener.rs +++ b/examples/rust/service_attributes/opener.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -32,15 +37,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("defined service attributes: {:?}", service.attributes()); + info!("defined service attributes: {:?}", service.attributes()); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {:?}", *sample); + info!("received: {:?}", *sample); } } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/service_types/ipc_publisher.rs b/examples/rust/service_types/ipc_publisher.rs index f584714fc..b6640a367 100644 --- a/examples/rust/service_types/ipc_publisher.rs +++ b/examples/rust/service_types/ipc_publisher.rs @@ -11,7 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(750); @@ -36,12 +41,12 @@ fn main() -> Result<(), Box> { let mut counter = 0u64; while node.wait(CYCLE_TIME).is_ok() { - println!("send: {counter}"); + info!("send: {counter}"); publisher.send_copy(counter)?; counter += 1; } - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/service_types/ipc_threadsafe_subscriber.rs b/examples/rust/service_types/ipc_threadsafe_subscriber.rs index 2bf481940..9975268cd 100644 --- a/examples/rust/service_types/ipc_threadsafe_subscriber.rs +++ b/examples/rust/service_types/ipc_threadsafe_subscriber.rs @@ -10,12 +10,17 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -extern crate alloc; - -use alloc::sync::Arc; use core::sync::atomic::{AtomicBool, Ordering}; use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; +use alloc::sync::Arc; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; +use iceoryx2_bb_posix::clock::nanosleep; +use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; const CYCLE_TIME: Duration = Duration::from_secs(1); static KEEP_RUNNING: AtomicBool = AtomicBool::new(true); @@ -41,25 +46,27 @@ fn main() -> Result<(), Box> { // The ports created by a thread-safe service implement `Send` and `Sync`, so they can be // be shared between threads. - let t = std::thread::spawn(move || { - while KEEP_RUNNING.load(Ordering::Relaxed) { - std::thread::sleep(CYCLE_TIME); - if let Some(sample) = in_thread_subscriber.receive().unwrap() { - println!("[thread] received: {}", sample.payload()); + let other_thread = ThreadBuilder::new() + .name(&ThreadName::from_bytes(b"other_thread").unwrap()) + .spawn(move || { + while KEEP_RUNNING.load(Ordering::Relaxed) { + nanosleep(CYCLE_TIME).unwrap(); + if let Some(sample) = in_thread_subscriber.receive().unwrap() { + info!("[thread] received: {}", sample.payload()); + } } - } - }); + })?; while node.wait(CYCLE_TIME).is_ok() { if let Some(sample) = subscriber.receive()? { - println!("[main] received: {}", sample.payload()); + info!("[main] received: {}", sample.payload()); } } KEEP_RUNNING.store(false, Ordering::Relaxed); - let _ = t.join(); + drop(other_thread); - println!("exit"); + info!("exit"); Ok(()) } diff --git a/examples/rust/service_types/local_pubsub.rs b/examples/rust/service_types/local_pubsub.rs index 8efbd7a34..aacfb7125 100644 --- a/examples/rust/service_types/local_pubsub.rs +++ b/examples/rust/service_types/local_pubsub.rs @@ -12,7 +12,14 @@ use core::sync::atomic::{AtomicBool, Ordering}; use core::time::Duration; + +extern crate alloc; +use alloc::boxed::Box; + use iceoryx2::prelude::*; +use iceoryx2_bb_log::info; +use iceoryx2_bb_posix::clock::nanosleep; +use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; const CYCLE_TIME: Duration = Duration::from_secs(1); static KEEP_RUNNING: AtomicBool = AtomicBool::new(true); @@ -35,9 +42,9 @@ fn background_thread() { let subscriber = service.subscriber_builder().create().unwrap(); while KEEP_RUNNING.load(Ordering::Relaxed) { - std::thread::sleep(CYCLE_TIME); + nanosleep(CYCLE_TIME).unwrap(); while let Some(sample) = subscriber.receive().unwrap() { - println!("[thread] received: {}", sample.payload()); + info!("[thread] received: {}", sample.payload()); } } } @@ -60,18 +67,20 @@ fn main() -> Result<(), Box> { .open_or_create()?; let publisher = service.publisher_builder().create()?; - let background_thread = std::thread::spawn(background_thread); + let background_thread = ThreadBuilder::new() + .name(&ThreadName::from_bytes(b"bgthread").unwrap()) + .spawn(background_thread)?; let mut counter = 0u64; while node.wait(CYCLE_TIME).is_ok() { - println!("send: {counter}"); + info!("send: {counter}"); publisher.send_copy(counter)?; counter += 1; } KEEP_RUNNING.store(false, Ordering::Relaxed); - let _ = background_thread.join(); - println!("exit"); + drop(background_thread); + info!("exit"); Ok(()) } From 187649bd00a182a39b4ab16ff33ac6e0ca3516bf Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 20:49:59 +0200 Subject: [PATCH 13/30] [#865] Remove indentation from log messages without origin --- iceoryx2-bb/log/src/logger/console.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iceoryx2-bb/log/src/logger/console.rs b/iceoryx2-bb/log/src/logger/console.rs index 7db90e0c7..6e1617eaa 100644 --- a/iceoryx2-bb/log/src/logger/console.rs +++ b/iceoryx2-bb/log/src/logger/console.rs @@ -170,7 +170,7 @@ impl crate::Log for Logger { Self::print_origin(log_level, &origin_str); } true => std::eprint!( - "{}{:9} {} ", + "{}{} {} ", Logger::counter_color(log_level), counter, Logger::log_level_string(log_level), From f09df27fbb6998a1c712b5c61bc38cd7740ab760 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 20:50:33 +0200 Subject: [PATCH 14/30] [#865] Only print '|' after logging origin --- iceoryx2-bb/log/src/logger/console.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iceoryx2-bb/log/src/logger/console.rs b/iceoryx2-bb/log/src/logger/console.rs index 6e1617eaa..c9e8f62b1 100644 --- a/iceoryx2-bb/log/src/logger/console.rs +++ b/iceoryx2-bb/log/src/logger/console.rs @@ -118,12 +118,13 @@ impl Logger { } fn print_message(log_level: crate::LogLevel, formatted_message: &str) { - Self::print("| ", Self::message_color(log_level), formatted_message); + Self::print("", Self::message_color(log_level), formatted_message); } fn print_origin(log_level: crate::LogLevel, origin: &str) { eprint!("{} ", Logger::log_level_string(log_level)); Self::print("", Logger::origin_color(log_level), origin); + eprint!("| "); } } From e631414f8fe629f7b63f61a01c252b78a4bf23d7 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 21:12:08 +0200 Subject: [PATCH 15/30] [#865] Export HashMap and HashSet implementations in iceoryx2-bb-container --- Cargo.lock | 8 +++----- examples/Cargo.toml | 2 -- examples/rust/event_multiplexing/wait.rs | 2 +- iceoryx2-bb/container/Cargo.toml | 6 ++++++ iceoryx2-bb/container/src/lib.rs | 10 ++++++++++ iceoryx2-cal/Cargo.toml | 1 - .../src/communication_channel/process_local.rs | 2 +- iceoryx2-cal/src/dynamic_storage/process_local.rs | 2 +- iceoryx2-cal/src/event/process_local_socketpair.rs | 5 +++-- iceoryx2-cal/src/monitoring/process_local.rs | 4 ++-- iceoryx2-cal/src/static_storage/process_local.rs | 2 +- iceoryx2-services/discovery/Cargo.toml | 2 +- .../discovery/src/service_discovery/tracker.rs | 3 ++- iceoryx2-tunnel/tunnel/Cargo.toml | 3 +-- iceoryx2-tunnel/tunnel/src/ports/event.rs | 3 +-- iceoryx2-tunnel/tunnel/src/tunnel.rs | 4 ++-- iceoryx2/Cargo.toml | 1 - iceoryx2/src/node/mod.rs | 3 +-- iceoryx2/src/waitset.rs | 3 +-- 19 files changed, 37 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a88f34eb6..e94ea342b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -927,7 +927,6 @@ name = "example" version = "0.7.0" dependencies = [ "clap", - "hashbrown 0.16.0", "iceoryx2", "iceoryx2-bb-container", "iceoryx2-bb-derive-macros", @@ -1295,7 +1294,6 @@ dependencies = [ name = "iceoryx2" version = "0.7.0" dependencies = [ - "hashbrown 0.16.0", "iceoryx2-bb-container", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", @@ -1329,6 +1327,7 @@ name = "iceoryx2-bb-container" version = "0.7.0" dependencies = [ "generic-tests", + "hashbrown 0.16.0", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", "iceoryx2-bb-elementary-traits", @@ -1506,7 +1505,6 @@ version = "0.7.0" dependencies = [ "cdr", "generic-tests", - "hashbrown 0.16.0", "iceoryx2-bb-container", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", @@ -1693,8 +1691,8 @@ name = "iceoryx2-services-discovery" version = "0.7.0" dependencies = [ "generic-tests", - "hashbrown 0.16.0", "iceoryx2", + "iceoryx2-bb-container", "iceoryx2-bb-elementary", "iceoryx2-bb-elementary-traits", "iceoryx2-bb-posix", @@ -1709,8 +1707,8 @@ name = "iceoryx2-tunnel" version = "0.7.0" dependencies = [ "generic-tests", - "hashbrown 0.16.0", "iceoryx2", + "iceoryx2-bb-container", "iceoryx2-bb-log", "iceoryx2-bb-posix", "iceoryx2-bb-testing", diff --git a/examples/Cargo.toml b/examples/Cargo.toml index a35ccd2b3..0b56e720e 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -21,8 +21,6 @@ iceoryx2-bb-log = { workspace = true } iceoryx2-bb-system-types = { workspace = true } iceoryx2-bb-posix = { workspace = true } -hashbrown = { workspace = true } - [dev-dependencies] clap = { workspace = true } diff --git a/examples/rust/event_multiplexing/wait.rs b/examples/rust/event_multiplexing/wait.rs index d502e5057..4028a1fae 100644 --- a/examples/rust/event_multiplexing/wait.rs +++ b/examples/rust/event_multiplexing/wait.rs @@ -17,10 +17,10 @@ use alloc::vec; use alloc::vec::Vec; use iceoryx2::{port::listener::Listener, prelude::*}; +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_log::info; use clap::Parser; -use hashbrown::HashMap; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); diff --git a/iceoryx2-bb/container/Cargo.toml b/iceoryx2-bb/container/Cargo.toml index 5ebd37f22..4082fdf99 100644 --- a/iceoryx2-bb/container/Cargo.toml +++ b/iceoryx2-bb/container/Cargo.toml @@ -10,13 +10,19 @@ repository = { workspace = true } rust-version = { workspace = true } version = { workspace = true } +[features] +default = ["std"] +std = [] + [dependencies] iceoryx2-bb-derive-macros = { workspace = true } iceoryx2-bb-elementary = { workspace = true } iceoryx2-bb-elementary-traits = { workspace = true } iceoryx2-bb-log = { workspace = true } iceoryx2-pal-concurrency-sync = { workspace = true } + serde = { workspace = true } +hashbrown = { workspace = true } [dev-dependencies] generic-tests = { workspace = true } diff --git a/iceoryx2-bb/container/src/lib.rs b/iceoryx2-bb/container/src/lib.rs index 13f656cd3..86516c068 100644 --- a/iceoryx2-bb/container/src/lib.rs +++ b/iceoryx2-bb/container/src/lib.rs @@ -102,6 +102,16 @@ pub mod semantic_string; /// A container to store key-value pairs. pub mod flatmap; +// TODO: Consider replacing with own implementations to reduce certification complexity +#[cfg(not(feature = "std"))] +pub use hashbrown::hash_map; +#[cfg(not(feature = "std"))] +pub use hashbrown::hash_set; +#[cfg(feature = "std")] +pub use std::collections::hash_map; +#[cfg(feature = "std")] +pub use std::collections::hash_set; + /// A trait that defines the interface of a string and several string variants. pub mod string; diff --git a/iceoryx2-cal/Cargo.toml b/iceoryx2-cal/Cargo.toml index 8f84007df..8e080e943 100644 --- a/iceoryx2-cal/Cargo.toml +++ b/iceoryx2-cal/Cargo.toml @@ -36,7 +36,6 @@ cdr = { workspace = true } toml = { workspace = true } sha1_smol = { workspace = true } tiny-fn = { workspace = true } -hashbrown = { workspace = true } [dev-dependencies] iceoryx2-bb-testing = { workspace = true } diff --git a/iceoryx2-cal/src/communication_channel/process_local.rs b/iceoryx2-cal/src/communication_channel/process_local.rs index f5c6040f4..85522501a 100644 --- a/iceoryx2-cal/src/communication_channel/process_local.rs +++ b/iceoryx2-cal/src/communication_channel/process_local.rs @@ -23,13 +23,13 @@ use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_lock_free::spsc::safely_overflowing_index_queue::*; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::*; use iceoryx2_bb_system_types::file_path::FilePath; use iceoryx2_bb_system_types::path::Path; -use hashbrown::HashMap; use once_cell::sync::Lazy; #[derive(Debug)] diff --git a/iceoryx2-cal/src/dynamic_storage/process_local.rs b/iceoryx2-cal/src/dynamic_storage/process_local.rs index 6e31a8605..2e04e4423 100644 --- a/iceoryx2-cal/src/dynamic_storage/process_local.rs +++ b/iceoryx2-cal/src/dynamic_storage/process_local.rs @@ -51,6 +51,7 @@ use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_elementary_traits::allocator::BaseAllocator; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_memory::heap_allocator::HeapAllocator; @@ -60,7 +61,6 @@ use iceoryx2_bb_system_types::file_path::FilePath; use iceoryx2_bb_system_types::path::Path; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; -use hashbrown::HashMap; use once_cell::sync::Lazy; pub use crate::dynamic_storage::*; diff --git a/iceoryx2-cal/src/event/process_local_socketpair.rs b/iceoryx2-cal/src/event/process_local_socketpair.rs index 523bf05d8..01f594e6b 100644 --- a/iceoryx2-cal/src/event/process_local_socketpair.rs +++ b/iceoryx2-cal/src/event/process_local_socketpair.rs @@ -16,6 +16,9 @@ use alloc::vec; use alloc::vec::Vec; pub use iceoryx2_bb_container::semantic_string::SemanticString; +pub use iceoryx2_bb_system_types::{file_name::FileName, file_path::FilePath, path::Path}; + +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_log::{debug, fail, fatal_panic}; use iceoryx2_bb_posix::{ file_descriptor::FileDescriptorBased, @@ -26,9 +29,7 @@ use iceoryx2_bb_posix::{ StreamingSocketPairReceiveError, StreamingSocketPairSendError, }, }; -pub use iceoryx2_bb_system_types::{file_name::FileName, file_path::FilePath, path::Path}; -use hashbrown::HashMap; use once_cell::sync::Lazy; use crate::named_concept::{ diff --git a/iceoryx2-cal/src/monitoring/process_local.rs b/iceoryx2-cal/src/monitoring/process_local.rs index a219d4192..f346c7e5b 100644 --- a/iceoryx2-cal/src/monitoring/process_local.rs +++ b/iceoryx2-cal/src/monitoring/process_local.rs @@ -10,14 +10,14 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use hashbrown::HashSet; - use alloc::vec; use alloc::vec::Vec; +use iceoryx2_bb_container::hash_set::HashSet; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::*; use iceoryx2_bb_system_types::{file_name::FileName, file_path::FilePath, path::Path}; + use once_cell::sync::Lazy; use crate::{ diff --git a/iceoryx2-cal/src/static_storage/process_local.rs b/iceoryx2-cal/src/static_storage/process_local.rs index 892387b72..2c50d0b49 100644 --- a/iceoryx2-cal/src/static_storage/process_local.rs +++ b/iceoryx2-cal/src/static_storage/process_local.rs @@ -47,12 +47,12 @@ use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::adaptive_wait::AdaptiveWaitBuilder; use iceoryx2_bb_posix::mutex::*; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicBool; -use hashbrown::HashMap; use once_cell::sync::Lazy; #[derive(Debug)] diff --git a/iceoryx2-services/discovery/Cargo.toml b/iceoryx2-services/discovery/Cargo.toml index 0718f1b67..0f9f1331e 100644 --- a/iceoryx2-services/discovery/Cargo.toml +++ b/iceoryx2-services/discovery/Cargo.toml @@ -17,11 +17,11 @@ path = "src/lib.rs" [dependencies] iceoryx2 = { workspace = true } +iceoryx2-bb-container = { workspace = true } iceoryx2-bb-elementary = { workspace = true } iceoryx2-bb-elementary-traits = { workspace = true } once_cell = { workspace = true } serde = { workspace = true } -hashbrown = { workspace = true } [dev-dependencies] iceoryx2-bb-testing = { workspace = true } diff --git a/iceoryx2-services/discovery/src/service_discovery/tracker.rs b/iceoryx2-services/discovery/src/service_discovery/tracker.rs index d592939c7..297ff0586 100644 --- a/iceoryx2-services/discovery/src/service_discovery/tracker.rs +++ b/iceoryx2-services/discovery/src/service_discovery/tracker.rs @@ -12,12 +12,13 @@ use alloc::vec::Vec; -use hashbrown::{hash_map::Entry, HashMap, HashSet}; use iceoryx2::{ config::Config, prelude::CallbackProgression, service::{service_id::ServiceId, Service, ServiceDetails, ServiceListError}, }; +use iceoryx2_bb_container::hash_map::{Entry, HashMap}; +use iceoryx2_bb_container::hash_set::HashSet; /// Errors that can occur during service synchronization. #[derive(Debug, Eq, PartialEq, Clone, Copy)] diff --git a/iceoryx2-tunnel/tunnel/Cargo.toml b/iceoryx2-tunnel/tunnel/Cargo.toml index 3a78355d1..e531a226a 100644 --- a/iceoryx2-tunnel/tunnel/Cargo.toml +++ b/iceoryx2-tunnel/tunnel/Cargo.toml @@ -17,12 +17,11 @@ path = "src/lib.rs" [dependencies] iceoryx2 = { workspace = true } +iceoryx2-bb-container = { workspace = true } iceoryx2-bb-log = { workspace = true } iceoryx2-tunnel-backend = { workspace = true } iceoryx2-services-discovery = { workspace = true } -hashbrown = { workspace = true } - [dev-dependencies] iceoryx2-bb-testing = { workspace = true } generic-tests = { workspace = true } diff --git a/iceoryx2-tunnel/tunnel/src/ports/event.rs b/iceoryx2-tunnel/tunnel/src/ports/event.rs index 6b819d346..ffbdcab29 100644 --- a/iceoryx2-tunnel/tunnel/src/ports/event.rs +++ b/iceoryx2-tunnel/tunnel/src/ports/event.rs @@ -10,14 +10,13 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -use hashbrown::HashSet; - use iceoryx2::{ node::Node, port::{listener::Listener, notifier::Notifier}, prelude::EventId, service::{static_config::StaticConfig, Service}, }; +use iceoryx2_bb_container::hash_set::HashSet; use iceoryx2_bb_log::{fail, trace}; #[derive(Debug, Eq, PartialEq, Clone, Copy)] diff --git a/iceoryx2-tunnel/tunnel/src/tunnel.rs b/iceoryx2-tunnel/tunnel/src/tunnel.rs index f52cc1ab8..ee18c7f17 100644 --- a/iceoryx2-tunnel/tunnel/src/tunnel.rs +++ b/iceoryx2-tunnel/tunnel/src/tunnel.rs @@ -19,14 +19,14 @@ use iceoryx2::service::service_id::ServiceId; use iceoryx2::service::static_config::messaging_pattern::MessagingPattern; use iceoryx2::service::static_config::StaticConfig; use iceoryx2::service::Service; +use iceoryx2_bb_container::hash_map::HashMap; +use iceoryx2_bb_container::hash_set::HashSet; use iceoryx2_bb_log::{fail, info, trace, warn}; use iceoryx2_tunnel_backend::traits::{ Backend, Discovery, EventRelay, PublishSubscribeRelay, RelayBuilder, RelayFactory, }; use iceoryx2_tunnel_backend::types::publish_subscribe::LoanFn; -use hashbrown::{HashMap, HashSet}; - use crate::discovery; use crate::ports::event::EventPorts; use crate::ports::publish_subscribe::PublishSubscribePorts; diff --git a/iceoryx2/Cargo.toml b/iceoryx2/Cargo.toml index 25362f543..65d17fc31 100644 --- a/iceoryx2/Cargo.toml +++ b/iceoryx2/Cargo.toml @@ -59,7 +59,6 @@ iceoryx2-cal = { workspace = true } iceoryx2-pal-concurrency-sync = { workspace = true } iceoryx2-pal-configuration = { workspace = true } -hashbrown = { workspace = true } serde = { workspace = true } toml = { workspace = true } tiny-fn = { workspace = true } diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index fe90b7287..5b170dd10 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -157,6 +157,7 @@ use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary::CallbackProgression; @@ -192,8 +193,6 @@ use crate::service::{ use crate::signal_handling_mode::SignalHandlingMode; use crate::{config::Config, service::config_scheme::node_details_config}; -use hashbrown::HashMap; - /// The system-wide unique id of a [`Node`] #[derive( Debug, diff --git a/iceoryx2/src/waitset.rs b/iceoryx2/src/waitset.rs index 072ac7890..40a7b4126 100644 --- a/iceoryx2/src/waitset.rs +++ b/iceoryx2/src/waitset.rs @@ -221,6 +221,7 @@ use core::{ use alloc::vec; use alloc::vec::Vec; +use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_elementary::CallbackProgression; use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::{ @@ -232,8 +233,6 @@ use iceoryx2_bb_posix::{ use iceoryx2_cal::reactor::*; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicUsize; -use hashbrown::HashMap; - use crate::signal_handling_mode::SignalHandlingMode; /// States why the [`WaitSet::wait_and_process()`] method returned. From 46b67c796f6abd5eb9a7f7eb17447bbceb44af3b Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 22:16:51 +0200 Subject: [PATCH 16/30] [#865] Update crate dependencies for Bazel build --- examples/rust/blackboard/BUILD.bazel | 2 ++ .../rust/blackboard_event_based_communication/BUILD.bazel | 2 ++ examples/rust/complex_data_types/BUILD.bazel | 1 + .../rust/cross_language_communication_basics/BUILD.bazel | 2 ++ .../cross_language_communication_complex_types/BUILD.bazel | 2 ++ .../rust/cross_language_communication_container/BUILD.bazel | 2 ++ examples/rust/discovery/BUILD.bazel | 1 + examples/rust/event/BUILD.bazel | 2 ++ examples/rust/event_based_communication/BUILD.bazel | 2 ++ examples/rust/event_multiplexing/BUILD.bazel | 3 +++ examples/rust/health_monitoring/BUILD.bazel | 4 ++++ examples/rust/publish_subscribe/BUILD.bazel | 2 ++ examples/rust/publish_subscribe_dynamic_data/BUILD.bazel | 2 ++ examples/rust/publish_subscribe_with_user_header/BUILD.bazel | 2 ++ examples/rust/request_response/BUILD.bazel | 2 ++ examples/rust/request_response_dynamic_data/BUILD.bazel | 2 ++ examples/rust/service_attributes/BUILD.bazel | 3 +++ examples/rust/service_types/BUILD.bazel | 5 +++++ iceoryx2-bb/container/BUILD.bazel | 1 + iceoryx2-ffi/c/BUILD.bazel | 3 +++ iceoryx2-services/discovery/BUILD.bazel | 1 + iceoryx2-tunnel/backend/BUILD.bazel | 1 + iceoryx2-tunnel/tunnel/BUILD.bazel | 1 + 23 files changed, 48 insertions(+) diff --git a/examples/rust/blackboard/BUILD.bazel b/examples/rust/blackboard/BUILD.bazel index dae5d7059..719e3f5a3 100644 --- a/examples/rust/blackboard/BUILD.bazel +++ b/examples/rust/blackboard/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], @@ -31,6 +32,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], diff --git a/examples/rust/blackboard_event_based_communication/BUILD.bazel b/examples/rust/blackboard_event_based_communication/BUILD.bazel index 64aa14dc4..358d7fe35 100644 --- a/examples/rust/blackboard_event_based_communication/BUILD.bazel +++ b/examples/rust/blackboard_event_based_communication/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", ], ) diff --git a/examples/rust/complex_data_types/BUILD.bazel b/examples/rust/complex_data_types/BUILD.bazel index a6451aa64..16346784d 100644 --- a/examples/rust/complex_data_types/BUILD.bazel +++ b/examples/rust/complex_data_types/BUILD.bazel @@ -22,6 +22,7 @@ rust_binary( "//iceoryx2-bb/container:iceoryx2-bb-container", "//iceoryx2-bb/elementary:iceoryx2-bb-elementary", "//iceoryx2-bb/elementary-traits:iceoryx2-bb-elementary-traits", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], proc_macro_deps = [ "//iceoryx2-bb/derive-macros:iceoryx2-bb-derive-macros", diff --git a/examples/rust/cross_language_communication_basics/BUILD.bazel b/examples/rust/cross_language_communication_basics/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/cross_language_communication_basics/BUILD.bazel +++ b/examples/rust/cross_language_communication_basics/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_complex_types/BUILD.bazel b/examples/rust/cross_language_communication_complex_types/BUILD.bazel index 555e2bd61..2809f2b0c 100644 --- a/examples/rust/cross_language_communication_complex_types/BUILD.bazel +++ b/examples/rust/cross_language_communication_complex_types/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], @@ -32,6 +33,7 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_container/BUILD.bazel b/examples/rust/cross_language_communication_container/BUILD.bazel index 555e2bd61..465facdd2 100644 --- a/examples/rust/cross_language_communication_container/BUILD.bazel +++ b/examples/rust/cross_language_communication_container/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], @@ -31,6 +32,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], diff --git a/examples/rust/discovery/BUILD.bazel b/examples/rust/discovery/BUILD.bazel index d7a2831fe..1bfda8e9c 100644 --- a/examples/rust/discovery/BUILD.bazel +++ b/examples/rust/discovery/BUILD.bazel @@ -19,5 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/event/BUILD.bazel b/examples/rust/event/BUILD.bazel index 526049f29..029fdf0d5 100644 --- a/examples/rust/event/BUILD.bazel +++ b/examples/rust/event/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -29,5 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/event_based_communication/BUILD.bazel b/examples/rust/event_based_communication/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/event_based_communication/BUILD.bazel +++ b/examples/rust/event_based_communication/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/event_multiplexing/BUILD.bazel b/examples/rust/event_multiplexing/BUILD.bazel index aeec98623..581c7e204 100644 --- a/examples/rust/event_multiplexing/BUILD.bazel +++ b/examples/rust/event_multiplexing/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", "@crate_index//:clap", ], @@ -31,6 +32,8 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", + "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", "@crate_index//:clap", ], diff --git a/examples/rust/health_monitoring/BUILD.bazel b/examples/rust/health_monitoring/BUILD.bazel index a0ed206db..b0094b571 100644 --- a/examples/rust/health_monitoring/BUILD.bazel +++ b/examples/rust/health_monitoring/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -41,6 +43,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -52,6 +55,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe/BUILD.bazel b/examples/rust/publish_subscribe/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/publish_subscribe/BUILD.bazel +++ b/examples/rust/publish_subscribe/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel b/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel +++ b/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe_with_user_header/BUILD.bazel b/examples/rust/publish_subscribe_with_user_header/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/publish_subscribe_with_user_header/BUILD.bazel +++ b/examples/rust/publish_subscribe_with_user_header/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/request_response/BUILD.bazel b/examples/rust/request_response/BUILD.bazel index ac064f398..4ae7561f0 100644 --- a/examples/rust/request_response/BUILD.bazel +++ b/examples/rust/request_response/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/request_response_dynamic_data/BUILD.bazel b/examples/rust/request_response_dynamic_data/BUILD.bazel index ac064f398..4ae7561f0 100644 --- a/examples/rust/request_response_dynamic_data/BUILD.bazel +++ b/examples/rust/request_response_dynamic_data/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/service_attributes/BUILD.bazel b/examples/rust/service_attributes/BUILD.bazel index 3ee4f5687..d688bd5b2 100644 --- a/examples/rust/service_attributes/BUILD.bazel +++ b/examples/rust/service_attributes/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -29,6 +30,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -39,5 +41,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/service_types/BUILD.bazel b/examples/rust/service_types/BUILD.bazel index d423f8b15..4dddb4011 100644 --- a/examples/rust/service_types/BUILD.bazel +++ b/examples/rust/service_types/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -29,6 +30,8 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", + "//iceoryx2-bb/posix:iceoryx2-bb-posix", ], ) @@ -39,5 +42,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", + "//iceoryx2-bb/posix:iceoryx2-bb-posix", ], ) diff --git a/iceoryx2-bb/container/BUILD.bazel b/iceoryx2-bb/container/BUILD.bazel index fce70e0b9..0eebe39bb 100644 --- a/iceoryx2-bb/container/BUILD.bazel +++ b/iceoryx2-bb/container/BUILD.bazel @@ -28,6 +28,7 @@ rust_library( "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync", "@crate_index//:serde", + "@crate_index//:hashbrown", ], proc_macro_deps = [ "//iceoryx2-bb/derive-macros:iceoryx2-bb-derive-macros", diff --git a/iceoryx2-ffi/c/BUILD.bazel b/iceoryx2-ffi/c/BUILD.bazel index 04bff1ada..f49f6ba1d 100644 --- a/iceoryx2-ffi/c/BUILD.bazel +++ b/iceoryx2-ffi/c/BUILD.bazel @@ -51,6 +51,7 @@ rust_shared_library( "//iceoryx2-bb/posix:iceoryx2-bb-posix", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "//iceoryx2-cal:iceoryx2-cal", + "//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync", "@crate_index//:serde", ], tags = ["exclusive"], @@ -73,6 +74,7 @@ rust_static_library( "//iceoryx2-bb/posix:iceoryx2-bb-posix", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "//iceoryx2-cal:iceoryx2-cal", + "//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync", "@crate_index//:serde", ], proc_macro_deps = [ @@ -120,6 +122,7 @@ rust_test( "//iceoryx2-bb/testing:iceoryx2-bb-testing", "//iceoryx2-pal/testing:iceoryx2-pal-testing", "//iceoryx2-cal:iceoryx2-cal", + "//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync", ], proc_macro_deps = [ "//iceoryx2-bb/derive-macros:iceoryx2-bb-derive-macros", diff --git a/iceoryx2-services/discovery/BUILD.bazel b/iceoryx2-services/discovery/BUILD.bazel index 52a277200..3bcae3612 100644 --- a/iceoryx2-services/discovery/BUILD.bazel +++ b/iceoryx2-services/discovery/BUILD.bazel @@ -24,6 +24,7 @@ rust_library( srcs = glob(["src/**/*.rs"]), deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/container:iceoryx2-bb-container", "//iceoryx2-bb/elementary:iceoryx2-bb-elementary", "//iceoryx2-bb/elementary-traits:iceoryx2-bb-elementary-traits", "@crate_index//:once_cell", diff --git a/iceoryx2-tunnel/backend/BUILD.bazel b/iceoryx2-tunnel/backend/BUILD.bazel index 09fbf1df1..cc41152ca 100644 --- a/iceoryx2-tunnel/backend/BUILD.bazel +++ b/iceoryx2-tunnel/backend/BUILD.bazel @@ -24,6 +24,7 @@ rust_library( srcs = glob(["src/**/*.rs"]), deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/posix:iceoryx2-bb-posix", "//iceoryx2-bb/testing:iceoryx2-bb-testing", ], ) diff --git a/iceoryx2-tunnel/tunnel/BUILD.bazel b/iceoryx2-tunnel/tunnel/BUILD.bazel index 560c74fe2..6e2353ee6 100644 --- a/iceoryx2-tunnel/tunnel/BUILD.bazel +++ b/iceoryx2-tunnel/tunnel/BUILD.bazel @@ -24,6 +24,7 @@ rust_library( srcs = glob(["src/**/*.rs"]), deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/container:iceoryx2-bb-container", "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-tunnel/backend:iceoryx2-tunnel-backend", "//iceoryx2-services/discovery:iceoryx2-services-discovery", From decb911a8c76b2b2045cdc3b9531621f5997f3ea Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Thu, 16 Oct 2025 22:37:41 +0200 Subject: [PATCH 17/30] [#865] Handle new features in Bazel build --- BUILD.bazel | 104 ++++++++++++++++++ Cargo.Bazel.lock | 210 ++++++++++++++++++++++++++++++------ iceoryx2-bb/log/BUILD.bazel | 36 ++++++- iceoryx2-bb/log/src/lib.rs | 5 +- iceoryx2-ffi/c/BUILD.bazel | 28 +++++ iceoryx2/BUILD.bazel | 28 +++++ 6 files changed, 374 insertions(+), 37 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 6978c0bab..d752ce992 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -45,6 +45,32 @@ config_setting( # Rust Feature Flags # +string_flag( + name = "feature_std", + build_setting_default = "on", + visibility = ["//visibility:public"], +) +config_setting( + name = "std_auto", + flag_values = { + "//:feature_std": "auto", + }, +) +config_setting( + name = "std_enabled", + flag_values = { + "//:feature_std": "on", + }, +) +# NOTE: while this seems superfluous, it is the pattern for cases where *_auto is on by default; +# therefore this target is introduced to keep all feature flags consistent +selects.config_setting_group( + name = "cfg_feature_std", + match_any = [ + "//:std_enabled", + ], +) + string_flag( name = "feature_dev_permissions", build_setting_default = "auto", @@ -71,6 +97,84 @@ selects.config_setting_group( ], ) +string_flag( + name = "feature_logger_buffer", + build_setting_default = "auto", + visibility = ["//visibility:public"], +) +config_setting( + name = "logger_buffer_auto", + flag_values = { + "//:feature_logger_buffer": "on", + }, +) +config_setting( + name = "logger_buffer_enabled", + flag_values = { + "//:feature_logger_buffer": "on", + }, +) +# NOTE: while this seems superfluous, it is the pattern for cases where *_auto is on by default; +# therefore this target is introduced to keep all feature flags consistent +selects.config_setting_group( + name = "cfg_feature_logger_buffer", + match_any = [ + "//:logger_buffer_enabled", + ], +) + +string_flag( + name = "feature_logger_file", + build_setting_default = "on", + visibility = ["//visibility:public"], +) +config_setting( + name = "logger_file_auto", + flag_values = { + "//:feature_logger_file": "auto", + }, +) +config_setting( + name = "logger_file_enabled", + flag_values = { + "//:feature_logger_file": "on", + }, +) +# NOTE: while this seems superfluous, it is the pattern for cases where *_auto is on by default; +# therefore this target is introduced to keep all feature flags consistent +selects.config_setting_group( + name = "cfg_feature_logger_file", + match_any = [ + "//:logger_file_enabled", + ], +) + +string_flag( + name = "feature_logger_console", + build_setting_default = "on", + visibility = ["//visibility:public"], +) +config_setting( + name = "logger_console_auto", + flag_values = { + "//:feature_logger_console": "auto", + }, +) +config_setting( + name = "logger_console_enabled", + flag_values = { + "//:feature_logger_console": "on", + }, +) +# NOTE: while this seems superfluous, it is the pattern for cases where *_auto is on by default; +# therefore this target is introduced to keep all feature flags consistent +selects.config_setting_group( + name = "cfg_feature_logger_console", + match_any = [ + "//:logger_console_enabled", + ], +) + string_flag( name = "feature_logger_log", build_setting_default = "auto", diff --git a/Cargo.Bazel.lock b/Cargo.Bazel.lock index aa1be60e3..177edcb88 100644 --- a/Cargo.Bazel.lock +++ b/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "8394a06b04b71f329bad98e9df648ee5df09f7dd9d0217b5f3b49c75cc54b251", + "checksum": "007b763f0f696cdf97955e2f50df14ddfd84826c265eb6c985851ac76c0ba1cb", "crates": { "addr2line 0.24.2": { "name": "addr2line", @@ -1404,7 +1404,7 @@ "deps": { "common": [ { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" } ], @@ -1434,7 +1434,7 @@ "deps": { "common": [ { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" } ], @@ -1464,7 +1464,7 @@ "deps": { "common": [ { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" } ], @@ -1494,7 +1494,7 @@ "deps": { "common": [ { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" } ], @@ -2207,7 +2207,7 @@ "target": "build_script_build" }, { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" }, { @@ -2743,14 +2743,14 @@ ], "license_file": "LICENSE.txt" }, - "clap 4.5.19": { + "clap 4.5.49": { "name": "clap", - "version": "4.5.19", + "version": "4.5.49", "package_url": "https://github.com/clap-rs/clap", "repository": { "Http": { - "url": "https://static.crates.io/crates/clap/4.5.19/download", - "sha256": "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" + "url": "https://static.crates.io/crates/clap/4.5.49/download", + "sha256": "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f" } }, "targets": [ @@ -2788,7 +2788,7 @@ "deps": { "common": [ { - "id": "clap_builder 4.5.19", + "id": "clap_builder 4.5.49", "target": "clap_builder" } ], @@ -2798,13 +2798,13 @@ "proc_macro_deps": { "common": [ { - "id": "clap_derive 4.5.18", + "id": "clap_derive 4.5.49", "target": "clap_derive" } ], "selects": {} }, - "version": "4.5.19" + "version": "4.5.49" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -2813,14 +2813,14 @@ ], "license_file": "LICENSE-APACHE" }, - "clap_builder 4.5.19": { + "clap_builder 4.5.49": { "name": "clap_builder", - "version": "4.5.19", + "version": "4.5.49", "package_url": "https://github.com/clap-rs/clap", "repository": { "Http": { - "url": "https://static.crates.io/crates/clap_builder/4.5.19/download", - "sha256": "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" + "url": "https://static.crates.io/crates/clap_builder/4.5.49/download", + "sha256": "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730" } }, "targets": [ @@ -2864,7 +2864,7 @@ "target": "anstyle" }, { - "id": "clap_lex 0.7.2", + "id": "clap_lex 0.7.6", "target": "clap_lex" }, { @@ -2875,7 +2875,7 @@ "selects": {} }, "edition": "2021", - "version": "4.5.19" + "version": "4.5.49" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -2884,14 +2884,14 @@ ], "license_file": "LICENSE-APACHE" }, - "clap_derive 4.5.18": { + "clap_derive 4.5.49": { "name": "clap_derive", - "version": "4.5.18", + "version": "4.5.49", "package_url": "https://github.com/clap-rs/clap", "repository": { "Http": { - "url": "https://static.crates.io/crates/clap_derive/4.5.18/download", - "sha256": "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" + "url": "https://static.crates.io/crates/clap_derive/4.5.49/download", + "sha256": "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" } }, "targets": [ @@ -2941,7 +2941,7 @@ "selects": {} }, "edition": "2021", - "version": "4.5.18" + "version": "4.5.49" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -2950,14 +2950,14 @@ ], "license_file": "LICENSE-APACHE" }, - "clap_lex 0.7.2": { + "clap_lex 0.7.6": { "name": "clap_lex", - "version": "0.7.2", + "version": "0.7.6", "package_url": "https://github.com/clap-rs/clap", "repository": { "Http": { - "url": "https://static.crates.io/crates/clap_lex/0.7.2/download", - "sha256": "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + "url": "https://static.crates.io/crates/clap_lex/0.7.6/download", + "sha256": "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" } }, "targets": [ @@ -2980,7 +2980,7 @@ "**" ], "edition": "2021", - "version": "0.7.2" + "version": "0.7.6" }, "license": "MIT OR Apache-2.0", "license_ids": [ @@ -5494,7 +5494,7 @@ "deps_dev": { "common": [ { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" } ], @@ -5715,6 +5715,44 @@ ], "license_file": "LICENSE-APACHE" }, + "foldhash 0.2.0": { + "name": "foldhash", + "version": "0.2.0", + "package_url": "https://github.com/orlp/foldhash", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/foldhash/0.2.0/download", + "sha256": "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + } + }, + "targets": [ + { + "Library": { + "crate_name": "foldhash", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "foldhash", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2021", + "version": "0.2.0" + }, + "license": "Zlib", + "license_ids": [ + "Zlib" + ], + "license_file": "LICENSE" + }, "form_urlencoded 1.2.1": { "name": "form_urlencoded", "version": "1.2.1", @@ -7024,6 +7062,73 @@ ], "license_file": "LICENSE-APACHE" }, + "hashbrown 0.16.0": { + "name": "hashbrown", + "version": "0.16.0", + "package_url": "https://github.com/rust-lang/hashbrown", + "repository": { + "Http": { + "url": "https://static.crates.io/crates/hashbrown/0.16.0/download", + "sha256": "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + } + }, + "targets": [ + { + "Library": { + "crate_name": "hashbrown", + "crate_root": "src/lib.rs", + "srcs": { + "allow_empty": true, + "include": [ + "**/*.rs" + ] + } + } + } + ], + "library_target_name": "hashbrown", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "allocator-api2", + "default", + "default-hasher", + "equivalent", + "inline-more", + "raw-entry" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "allocator-api2 0.2.21", + "target": "allocator_api2" + }, + { + "id": "equivalent 1.0.1", + "target": "equivalent" + }, + { + "id": "foldhash 0.2.0", + "target": "foldhash" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "0.16.0" + }, + "license": "MIT OR Apache-2.0", + "license_ids": [ + "Apache-2.0", + "MIT" + ], + "license_file": "LICENSE-APACHE" + }, "heck 0.4.1": { "name": "heck", "version": "0.4.1", @@ -7738,6 +7843,16 @@ "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "default", + "logger_buffer", + "logger_console", + "logger_file", + "std" + ], + "selects": {} + }, "deps": { "common": [ { @@ -7840,8 +7955,19 @@ "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "default", + "std" + ], + "selects": {} + }, "deps": { "common": [ + { + "id": "hashbrown 0.16.0", + "target": "hashbrown" + }, { "id": "serde 1.0.219", "target": "serde" @@ -8106,6 +8232,16 @@ "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "default", + "logger_buffer", + "logger_console", + "logger_file", + "std" + ], + "selects": {} + }, "edition": "2021", "version": "0.7.0" }, @@ -8555,7 +8691,7 @@ "target": "cargo_metadata" }, { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" }, { @@ -8697,6 +8833,13 @@ "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "default", + "std" + ], + "selects": {} + }, "deps": { "common": [ { @@ -9291,7 +9434,7 @@ "deps": { "common": [ { - "id": "clap 4.5.19", + "id": "clap 4.5.49", "target": "clap" } ], @@ -30767,11 +30910,12 @@ "cbindgen 0.27.0", "cc 1.2.21", "cdr 0.2.4", - "clap 4.5.19", + "clap 4.5.49", "colored 2.1.0", "dialoguer 0.8.0", "dirs 5.0.1", "enum-iterator 2.1.0", + "hashbrown 0.16.0", "human-panic 2.0.2", "lazy_static 1.5.0", "once_cell 1.20.2", diff --git a/iceoryx2-bb/log/BUILD.bazel b/iceoryx2-bb/log/BUILD.bazel index c70259a6d..2f4ab8e32 100644 --- a/iceoryx2-bb/log/BUILD.bazel +++ b/iceoryx2-bb/log/BUILD.bazel @@ -24,17 +24,47 @@ rust_library( name = "iceoryx2-bb-log", srcs = glob(["src/**/*.rs"]), crate_features = select({ + "//:cfg_feature_std": [ + "std" + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_buffer": [ + "logger_buffer", + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_file": [ + "logger_file", + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_console": [ + "logger_console", + ], + "//conditions:default": [], + }) + select({ "//:cfg_feature_logger_log": [ - "logger_log" + "logger_log", ], "//conditions:default": [], }) + select({ "//:cfg_feature_logger_tracing": [ - "logger_tracing" + "logger_tracing", ], "//conditions:default": [], }), deps = [ "//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync", - ], + ] + select({ + "//:cfg_feature_logger_log": [ + "@crate_index//:log", + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_tracing": [ + "@crate_index//:tracing", + ], + "//conditions:default": [], + }), ) diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index daef6c98d..9d2cb765d 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -178,7 +178,10 @@ static DEFAULT_LOGGER: logger::tracing::Logger = logger::tracing::Logger::new(); #[cfg(feature = "logger_log")] static DEFAULT_LOGGER: logger::log::Logger = logger::log::Logger::new(); -#[cfg(not(any(feature = "logger_log", feature = "logger_tracing")))] +#[cfg(all( + not(any(feature = "logger_log", feature = "logger_tracing")), + feature = "logger_console" +))] static DEFAULT_LOGGER: logger::console::Logger = logger::console::Logger::new(); #[cfg(not(any( diff --git a/iceoryx2-ffi/c/BUILD.bazel b/iceoryx2-ffi/c/BUILD.bazel index f49f6ba1d..6a9c0b321 100644 --- a/iceoryx2-ffi/c/BUILD.bazel +++ b/iceoryx2-ffi/c/BUILD.bazel @@ -41,6 +41,20 @@ genrule( rust_shared_library( name = "iceoryx2-ffi-c-shared-rust", srcs = glob(["src/**/*.rs"]), + crate_features = select({ + "//:cfg_feature_std": [ + "std", + "logger_buffer", + "logger_console", + "logger_file" + ], + "//conditions:default": [ + "std", + "logger_buffer", + "logger_console", + "logger_file" + ], + }), deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", @@ -64,6 +78,20 @@ rust_shared_library( rust_static_library( name = "iceoryx2-ffi-c-static-rust", srcs = glob(["src/**/*.rs"]), + crate_features = select({ + "//:cfg_feature_std": [ + "std", + "logger_buffer", + "logger_console", + "logger_file" + ], + "//conditions:default": [ + "std", + "logger_buffer", + "logger_console", + "logger_file" + ], + }), deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", diff --git a/iceoryx2/BUILD.bazel b/iceoryx2/BUILD.bazel index b3b52513b..273fdc175 100644 --- a/iceoryx2/BUILD.bazel +++ b/iceoryx2/BUILD.bazel @@ -37,6 +37,34 @@ rust_library( "logger_tracing" ], "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_buffer": [ + "logger_buffer" + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_file": [ + "logger_file" + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_logger_console": [ + "logger_console" + ], + "//conditions:default": [], + }) + select({ + "//:cfg_feature_std": [ + "std", + "logger_buffer", + "logger_console", + "logger_file" + ], + "//conditions:default": [ + "std", + "logger_buffer", + "logger_console", + "logger_file" + ], }), deps = [ "//iceoryx2-bb/container:iceoryx2-bb-container", From bac836831a6ecda4824ca48f8eba848cb049d00a Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Fri, 17 Oct 2025 01:58:00 +0200 Subject: [PATCH 18/30] [#865] Add release notes --- doc/release-notes/iceoryx2-unreleased.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release-notes/iceoryx2-unreleased.md b/doc/release-notes/iceoryx2-unreleased.md index 4ead3265f..64859df97 100644 --- a/doc/release-notes/iceoryx2-unreleased.md +++ b/doc/release-notes/iceoryx2-unreleased.md @@ -63,6 +63,8 @@ * Decoupled tunnel implementation from tunelling mechanism [#845](https://github.com/eclipse-iceoryx/iceoryx2/issues/845) +* Explicitly use components from `core` and `alloc` in all Rust code + [#865](https://github.com/eclipse-iceoryx/iceoryx2/issues/865) * Updated all dependencies and increased MSRV to 1.83 [#1105](https://github.com/eclipse-iceoryx/iceoryx2/issues/1105) * Remove pre-compiled `noop.exe` used for testing command exeuction on Windows From f8c52509b3d9fffa244d7e0aeb910ef9c66edee4 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Fri, 17 Oct 2025 15:18:57 +0200 Subject: [PATCH 19/30] [#865] Use BTreeMap and BTreeSet instead of HashMap and HashSet --- Cargo.Bazel.lock | 112 +----------------- Cargo.lock | 18 --- Cargo.toml | 1 - examples/rust/event_multiplexing/wait.rs | 6 +- iceoryx2-bb/container/BUILD.bazel | 1 - iceoryx2-bb/container/Cargo.toml | 1 - iceoryx2-bb/container/src/lib.rs | 10 -- iceoryx2-bb/system-types/src/file_name.rs | 2 +- .../communication_channel/process_local.rs | 8 +- .../src/dynamic_storage/process_local.rs | 12 +- .../src/event/process_local_socketpair.rs | 8 +- iceoryx2-cal/src/monitoring/process_local.rs | 9 +- .../src/static_storage/process_local.rs | 8 +- .../src/service_discovery/tracker.rs | 11 +- iceoryx2-tunnel/tunnel/src/ports/event.rs | 5 +- iceoryx2-tunnel/tunnel/src/tunnel.rs | 24 ++-- iceoryx2/src/node/mod.rs | 8 +- iceoryx2/src/service/service_id.rs | 4 +- iceoryx2/src/waitset.rs | 16 +-- 19 files changed, 64 insertions(+), 200 deletions(-) diff --git a/Cargo.Bazel.lock b/Cargo.Bazel.lock index 177edcb88..3a45cc84f 100644 --- a/Cargo.Bazel.lock +++ b/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "007b763f0f696cdf97955e2f50df14ddfd84826c265eb6c985851ac76c0ba1cb", + "checksum": "25a086a2f90731beae6ada9b9eb87796ac43c9abca37cc3fef9112fee86a14e2", "crates": { "addr2line 0.24.2": { "name": "addr2line", @@ -5715,44 +5715,6 @@ ], "license_file": "LICENSE-APACHE" }, - "foldhash 0.2.0": { - "name": "foldhash", - "version": "0.2.0", - "package_url": "https://github.com/orlp/foldhash", - "repository": { - "Http": { - "url": "https://static.crates.io/crates/foldhash/0.2.0/download", - "sha256": "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - } - }, - "targets": [ - { - "Library": { - "crate_name": "foldhash", - "crate_root": "src/lib.rs", - "srcs": { - "allow_empty": true, - "include": [ - "**/*.rs" - ] - } - } - } - ], - "library_target_name": "foldhash", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "edition": "2021", - "version": "0.2.0" - }, - "license": "Zlib", - "license_ids": [ - "Zlib" - ], - "license_file": "LICENSE" - }, "form_urlencoded 1.2.1": { "name": "form_urlencoded", "version": "1.2.1", @@ -7062,73 +7024,6 @@ ], "license_file": "LICENSE-APACHE" }, - "hashbrown 0.16.0": { - "name": "hashbrown", - "version": "0.16.0", - "package_url": "https://github.com/rust-lang/hashbrown", - "repository": { - "Http": { - "url": "https://static.crates.io/crates/hashbrown/0.16.0/download", - "sha256": "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" - } - }, - "targets": [ - { - "Library": { - "crate_name": "hashbrown", - "crate_root": "src/lib.rs", - "srcs": { - "allow_empty": true, - "include": [ - "**/*.rs" - ] - } - } - } - ], - "library_target_name": "hashbrown", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "crate_features": { - "common": [ - "allocator-api2", - "default", - "default-hasher", - "equivalent", - "inline-more", - "raw-entry" - ], - "selects": {} - }, - "deps": { - "common": [ - { - "id": "allocator-api2 0.2.21", - "target": "allocator_api2" - }, - { - "id": "equivalent 1.0.1", - "target": "equivalent" - }, - { - "id": "foldhash 0.2.0", - "target": "foldhash" - } - ], - "selects": {} - }, - "edition": "2021", - "version": "0.16.0" - }, - "license": "MIT OR Apache-2.0", - "license_ids": [ - "Apache-2.0", - "MIT" - ], - "license_file": "LICENSE-APACHE" - }, "heck 0.4.1": { "name": "heck", "version": "0.4.1", @@ -7964,10 +7859,6 @@ }, "deps": { "common": [ - { - "id": "hashbrown 0.16.0", - "target": "hashbrown" - }, { "id": "serde 1.0.219", "target": "serde" @@ -30915,7 +30806,6 @@ "dialoguer 0.8.0", "dirs 5.0.1", "enum-iterator 2.1.0", - "hashbrown 0.16.0", "human-panic 2.0.2", "lazy_static 1.5.0", "once_cell 1.20.2", diff --git a/Cargo.lock b/Cargo.lock index e94ea342b..ee58f9d37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -968,12 +968,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1174,17 +1168,6 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" -[[package]] -name = "hashbrown" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", -] - [[package]] name = "heck" version = "0.4.1" @@ -1327,7 +1310,6 @@ name = "iceoryx2-bb-container" version = "0.7.0" dependencies = [ "generic-tests", - "hashbrown 0.16.0", "iceoryx2-bb-derive-macros", "iceoryx2-bb-elementary", "iceoryx2-bb-elementary-traits", diff --git a/Cargo.toml b/Cargo.toml index 724bf109a..fee000b43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,7 +118,6 @@ enum-iterator = { version = "2.1.0" } better-panic = { version = "0.3.0" } colored = { version = "2.1" } generic-tests = { version = "0.1.2" } -hashbrown = { version = "0.16" } human-panic = { version = "2.0.2" } lazy_static = { version = "1.4.0" } libc = { version = "0.2.169", features = ['extra_traits'] } diff --git a/examples/rust/event_multiplexing/wait.rs b/examples/rust/event_multiplexing/wait.rs index 4028a1fae..de8287bda 100644 --- a/examples/rust/event_multiplexing/wait.rs +++ b/examples/rust/event_multiplexing/wait.rs @@ -12,12 +12,12 @@ extern crate alloc; use alloc::boxed::Box; +use alloc::collections::BTreeMap; use alloc::string::String; use alloc::vec; use alloc::vec::Vec; use iceoryx2::{port::listener::Listener, prelude::*}; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_log::info; use clap::Parser; @@ -41,10 +41,10 @@ fn main() -> Result<(), Box> { let waitset = WaitSetBuilder::new().create::()?; let mut listeners = vec![]; - let mut listener_attachments: HashMap< + let mut listener_attachments: BTreeMap< WaitSetAttachmentId, (&String, &Listener), - > = HashMap::new(); + > = BTreeMap::new(); let mut guards = vec![]; // create a listener for every service diff --git a/iceoryx2-bb/container/BUILD.bazel b/iceoryx2-bb/container/BUILD.bazel index 0eebe39bb..fce70e0b9 100644 --- a/iceoryx2-bb/container/BUILD.bazel +++ b/iceoryx2-bb/container/BUILD.bazel @@ -28,7 +28,6 @@ rust_library( "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-pal/concurrency-sync:iceoryx2-pal-concurrency-sync", "@crate_index//:serde", - "@crate_index//:hashbrown", ], proc_macro_deps = [ "//iceoryx2-bb/derive-macros:iceoryx2-bb-derive-macros", diff --git a/iceoryx2-bb/container/Cargo.toml b/iceoryx2-bb/container/Cargo.toml index 4082fdf99..bcd895c94 100644 --- a/iceoryx2-bb/container/Cargo.toml +++ b/iceoryx2-bb/container/Cargo.toml @@ -22,7 +22,6 @@ iceoryx2-bb-log = { workspace = true } iceoryx2-pal-concurrency-sync = { workspace = true } serde = { workspace = true } -hashbrown = { workspace = true } [dev-dependencies] generic-tests = { workspace = true } diff --git a/iceoryx2-bb/container/src/lib.rs b/iceoryx2-bb/container/src/lib.rs index 86516c068..13f656cd3 100644 --- a/iceoryx2-bb/container/src/lib.rs +++ b/iceoryx2-bb/container/src/lib.rs @@ -102,16 +102,6 @@ pub mod semantic_string; /// A container to store key-value pairs. pub mod flatmap; -// TODO: Consider replacing with own implementations to reduce certification complexity -#[cfg(not(feature = "std"))] -pub use hashbrown::hash_map; -#[cfg(not(feature = "std"))] -pub use hashbrown::hash_set; -#[cfg(feature = "std")] -pub use std::collections::hash_map; -#[cfg(feature = "std")] -pub use std::collections::hash_set; - /// A trait that defines the interface of a string and several string variants. pub mod string; diff --git a/iceoryx2-bb/system-types/src/file_name.rs b/iceoryx2-bb/system-types/src/file_name.rs index d91de9de1..a62f9173b 100644 --- a/iceoryx2-bb/system-types/src/file_name.rs +++ b/iceoryx2-bb/system-types/src/file_name.rs @@ -80,7 +80,7 @@ semantic_string! { normalize: normalize } -#[derive(Debug, Clone, Copy, Eq, ZeroCopySend)] +#[derive(Debug, Clone, Copy, Eq, Ord, PartialOrd, ZeroCopySend)] #[repr(C)] pub struct RestrictedFileName { value: iceoryx2_bb_container::string::StaticString, diff --git a/iceoryx2-cal/src/communication_channel/process_local.rs b/iceoryx2-cal/src/communication_channel/process_local.rs index 85522501a..9472f49ee 100644 --- a/iceoryx2-cal/src/communication_channel/process_local.rs +++ b/iceoryx2-cal/src/communication_channel/process_local.rs @@ -18,12 +18,12 @@ use crate::static_storage::file::NamedConceptConfiguration; use core::fmt::Debug; +use alloc::collections::BTreeMap; use alloc::format; use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_lock_free::spsc::safely_overflowing_index_queue::*; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::*; @@ -52,12 +52,12 @@ struct StorageEntry { content: Arc, } -static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = +static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = Lazy::new(MutexHandle::new); -static PROCESS_LOCAL_CHANNELS: Lazy>> = Lazy::new(|| { +static PROCESS_LOCAL_CHANNELS: Lazy>> = Lazy::new(|| { let result = MutexBuilder::new() .is_interprocess_capable(false) - .create(HashMap::new(), &PROCESS_LOCAL_MTX_HANDLE); + .create(BTreeMap::new(), &PROCESS_LOCAL_MTX_HANDLE); if result.is_err() { fatal_panic!(from "PROCESS_LOCAL_CHANNELS", "Failed to create process global communication channels"); diff --git a/iceoryx2-cal/src/dynamic_storage/process_local.rs b/iceoryx2-cal/src/dynamic_storage/process_local.rs index 2e04e4423..f28f9781a 100644 --- a/iceoryx2-cal/src/dynamic_storage/process_local.rs +++ b/iceoryx2-cal/src/dynamic_storage/process_local.rs @@ -44,6 +44,7 @@ use core::marker::PhantomData; use core::ptr::NonNull; use core::sync::atomic::Ordering; +use alloc::collections::BTreeMap; use alloc::format; use alloc::string::String; use alloc::string::ToString; @@ -51,7 +52,6 @@ use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_elementary_traits::allocator::BaseAllocator; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_memory::heap_allocator::HeapAllocator; @@ -190,12 +190,12 @@ impl Drop for StorageDetails { unsafe impl Send for StorageDetails {} unsafe impl Sync for StorageDetails {} -static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = +static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = Lazy::new(MutexHandle::new); -static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { +static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { let result = MutexBuilder::new() .is_interprocess_capable(false) - .create(HashMap::new(), &PROCESS_LOCAL_MTX_HANDLE); + .create(BTreeMap::new(), &PROCESS_LOCAL_MTX_HANDLE); if result.is_err() { fatal_panic!(from "PROCESS_LOCAL_STORAGE", "Failed to create global dynamic storage"); @@ -376,7 +376,7 @@ impl NamedConceptBuilder> for Build impl Builder<'_, T> { fn open_impl( &self, - guard: &mut MutexGuard<'static, HashMap>, + guard: &mut MutexGuard<'static, BTreeMap>, ) -> Result, DynamicStorageOpenError> { let msg = "Failed to open dynamic storage"; @@ -403,7 +403,7 @@ impl Builder<'_, T> { fn create_impl( &mut self, - guard: &mut MutexGuard<'static, HashMap>, + guard: &mut MutexGuard<'static, BTreeMap>, initial_value: T, ) -> Result, DynamicStorageCreateError> { let msg = "Failed to create dynamic storage"; diff --git a/iceoryx2-cal/src/event/process_local_socketpair.rs b/iceoryx2-cal/src/event/process_local_socketpair.rs index 01f594e6b..a98e74d9b 100644 --- a/iceoryx2-cal/src/event/process_local_socketpair.rs +++ b/iceoryx2-cal/src/event/process_local_socketpair.rs @@ -12,13 +12,13 @@ use core::time::Duration; +use alloc::collections::BTreeMap; use alloc::vec; use alloc::vec::Vec; pub use iceoryx2_bb_container::semantic_string::SemanticString; pub use iceoryx2_bb_system_types::{file_name::FileName, file_path::FilePath, path::Path}; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_log::{debug, fail, fatal_panic}; use iceoryx2_bb_posix::{ file_descriptor::FileDescriptorBased, @@ -49,12 +49,12 @@ struct StorageEntry { notifier: StreamingSocket, } -static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = +static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = Lazy::new(MutexHandle::new); -static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { +static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { let result = MutexBuilder::new() .is_interprocess_capable(false) - .create(HashMap::new(), &PROCESS_LOCAL_MTX_HANDLE); + .create(BTreeMap::new(), &PROCESS_LOCAL_MTX_HANDLE); if result.is_err() { fatal_panic!(from "PROCESS_LOCAL_STORAGE", "Failed to create global dynamic storage"); diff --git a/iceoryx2-cal/src/monitoring/process_local.rs b/iceoryx2-cal/src/monitoring/process_local.rs index f346c7e5b..c583d7a29 100644 --- a/iceoryx2-cal/src/monitoring/process_local.rs +++ b/iceoryx2-cal/src/monitoring/process_local.rs @@ -10,10 +10,10 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::collections::BTreeSet; use alloc::vec; use alloc::vec::Vec; -use iceoryx2_bb_container::hash_set::HashSet; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::mutex::*; use iceoryx2_bb_system_types::{file_name::FileName, file_path::FilePath, path::Path}; @@ -30,11 +30,12 @@ use super::{ NamedConcept, NamedConceptBuilder, NamedConceptMgmt, State, }; -static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = Lazy::new(MutexHandle::new); -static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { +static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = + Lazy::new(MutexHandle::new); +static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { let result = MutexBuilder::new() .is_interprocess_capable(false) - .create(HashSet::new(), &PROCESS_LOCAL_MTX_HANDLE); + .create(BTreeSet::new(), &PROCESS_LOCAL_MTX_HANDLE); if result.is_err() { fatal_panic!(from "PROCESS_LOCAL_STORAGE", "Failed to create global monitoring storage"); diff --git a/iceoryx2-cal/src/static_storage/process_local.rs b/iceoryx2-cal/src/static_storage/process_local.rs index 2c50d0b49..85197cfad 100644 --- a/iceoryx2-cal/src/static_storage/process_local.rs +++ b/iceoryx2-cal/src/static_storage/process_local.rs @@ -43,11 +43,11 @@ pub use crate::static_storage::*; use core::sync::atomic::Ordering; +use alloc::collections::BTreeMap; use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_log::{fail, fatal_panic}; use iceoryx2_bb_posix::adaptive_wait::AdaptiveWaitBuilder; use iceoryx2_bb_posix::mutex::*; @@ -66,12 +66,12 @@ struct StorageEntry { content: Arc, } -static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = +static PROCESS_LOCAL_MTX_HANDLE: Lazy>> = Lazy::new(MutexHandle::new); -static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { +static PROCESS_LOCAL_STORAGE: Lazy>> = Lazy::new(|| { let result = MutexBuilder::new() .is_interprocess_capable(false) - .create(HashMap::new(), &PROCESS_LOCAL_MTX_HANDLE); + .create(BTreeMap::new(), &PROCESS_LOCAL_MTX_HANDLE); if result.is_err() { fatal_panic!(from "PROCESS_LOCAL_STORAGE", "Failed to create global static storage"); diff --git a/iceoryx2-services/discovery/src/service_discovery/tracker.rs b/iceoryx2-services/discovery/src/service_discovery/tracker.rs index 297ff0586..692eef384 100644 --- a/iceoryx2-services/discovery/src/service_discovery/tracker.rs +++ b/iceoryx2-services/discovery/src/service_discovery/tracker.rs @@ -10,6 +10,9 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::collections::btree_map::Entry; +use alloc::collections::BTreeMap; +use alloc::collections::BTreeSet; use alloc::vec::Vec; use iceoryx2::{ @@ -17,8 +20,6 @@ use iceoryx2::{ prelude::CallbackProgression, service::{service_id::ServiceId, Service, ServiceDetails, ServiceListError}, }; -use iceoryx2_bb_container::hash_map::{Entry, HashMap}; -use iceoryx2_bb_container::hash_set::HashSet; /// Errors that can occur during service synchronization. #[derive(Debug, Eq, PartialEq, Clone, Copy)] @@ -58,7 +59,7 @@ impl From for SyncError { #[derive(Debug, Default)] pub struct Tracker { config: Config, - services: HashMap>, + services: BTreeMap>, } impl Tracker { @@ -66,7 +67,7 @@ impl Tracker { pub fn new(config: &Config) -> Self { Self { config: config.clone(), - services: HashMap::new(), + services: BTreeMap::new(), } } @@ -88,7 +89,7 @@ impl Tracker { /// * A vector of service details for services that are no longer available, these details are /// no longer stored in the tracker pub fn sync(&mut self) -> Result<(Vec, Vec>), SyncError> { - let mut discovered_ids = HashSet::::new(); + let mut discovered_ids = BTreeSet::::new(); let mut added_ids = Vec::::new(); S::list(&self.config, |service| { diff --git a/iceoryx2-tunnel/tunnel/src/ports/event.rs b/iceoryx2-tunnel/tunnel/src/ports/event.rs index ffbdcab29..d8b9d5371 100644 --- a/iceoryx2-tunnel/tunnel/src/ports/event.rs +++ b/iceoryx2-tunnel/tunnel/src/ports/event.rs @@ -10,13 +10,14 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::collections::BTreeSet; + use iceoryx2::{ node::Node, port::{listener::Listener, notifier::Notifier}, prelude::EventId, service::{static_config::StaticConfig, Service}, }; -use iceoryx2_bb_container::hash_set::HashSet; use iceoryx2_bb_log::{fail, trace}; #[derive(Debug, Eq, PartialEq, Clone, Copy)] @@ -158,7 +159,7 @@ impl EventPorts { PropagateFn: FnMut(EventId) -> Result<(), E>, { let mut propagated = false; - let mut received_ids: HashSet = HashSet::new(); + let mut received_ids: BTreeSet = BTreeSet::new(); // Consolidate pending event ids while let Ok(event_id) = self.listener.try_wait_one() { diff --git a/iceoryx2-tunnel/tunnel/src/tunnel.rs b/iceoryx2-tunnel/tunnel/src/tunnel.rs index ee18c7f17..5496baee1 100644 --- a/iceoryx2-tunnel/tunnel/src/tunnel.rs +++ b/iceoryx2-tunnel/tunnel/src/tunnel.rs @@ -12,6 +12,8 @@ use core::fmt::Debug; +use alloc::collections::BTreeMap; +use alloc::collections::BTreeSet; use alloc::string::String; use iceoryx2::node::{Node, NodeBuilder, NodeId}; @@ -19,8 +21,6 @@ use iceoryx2::service::service_id::ServiceId; use iceoryx2::service::static_config::messaging_pattern::MessagingPattern; use iceoryx2::service::static_config::StaticConfig; use iceoryx2::service::Service; -use iceoryx2_bb_container::hash_map::HashMap; -use iceoryx2_bb_container::hash_set::HashSet; use iceoryx2_bb_log::{fail, info, trace, warn}; use iceoryx2_tunnel_backend::traits::{ Backend, Discovery, EventRelay, PublishSubscribeRelay, RelayBuilder, RelayFactory, @@ -85,30 +85,30 @@ impl core::error::Error for PropagateError {} #[derive(Debug)] pub(crate) struct Ports { - pub(crate) publish_subscribe: HashMap>, - pub(crate) event: HashMap>, + pub(crate) publish_subscribe: BTreeMap>, + pub(crate) event: BTreeMap>, } impl Ports { pub fn new() -> Self { Self { - publish_subscribe: HashMap::new(), - event: HashMap::new(), + publish_subscribe: BTreeMap::new(), + event: BTreeMap::new(), } } } #[derive(Debug, Default)] pub struct Relays> { - publish_subscribe: HashMap, - event: HashMap, + publish_subscribe: BTreeMap, + event: BTreeMap, } impl> Relays { pub fn new() -> Self { Self { - publish_subscribe: HashMap::new(), - event: HashMap::new(), + publish_subscribe: BTreeMap::new(), + event: BTreeMap::new(), } } } @@ -270,7 +270,7 @@ impl Backend + Debug> Tunnel { Ok(()) } - pub fn tunneled_services(&self) -> HashSet { + pub fn tunneled_services(&self) -> BTreeSet { self.ports .publish_subscribe .keys() @@ -284,7 +284,7 @@ fn on_discovery + Debug>( static_config: &StaticConfig, node: &Node, backend: &B, - services: &HashSet, + services: &BTreeSet, ports: &mut Ports, relays: &mut Relays, ) -> Result<(), DiscoveryError> { diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index 5b170dd10..f81350856 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -150,6 +150,7 @@ use core::marker::PhantomData; use core::sync::atomic::Ordering; use core::time::Duration; +use alloc::collections::BTreeMap; use alloc::format; use alloc::string::String; use alloc::string::ToString; @@ -157,7 +158,6 @@ use alloc::sync::Arc; use alloc::vec; use alloc::vec::Vec; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_container::semantic_string::SemanticString; use iceoryx2_bb_derive_macros::ZeroCopySend; use iceoryx2_bb_elementary::CallbackProgression; @@ -743,7 +743,7 @@ fn remove_node( #[derive(Debug)] pub(crate) struct RegisteredServices { - handle: MutexHandle>, + handle: MutexHandle>, } unsafe impl Send for RegisteredServices {} @@ -756,7 +756,7 @@ impl RegisteredServices { MutexBuilder::new() .is_interprocess_capable(false) .mutex_type(MutexType::Normal) - .create(HashMap::new(), &handle) + .create(BTreeMap::new(), &handle) .expect("Failed to create mutex"); Self { handle } @@ -812,7 +812,7 @@ impl RegisteredServices { } } - fn mutex(&self) -> Mutex<'_, '_, HashMap> { + fn mutex(&self) -> Mutex<'_, '_, BTreeMap> { // Safe - the mutex is initialized when constructing the struct and // not interacted with by anything else. unsafe { Mutex::from_handle(&self.handle) } diff --git a/iceoryx2/src/service/service_id.rs b/iceoryx2/src/service/service_id.rs index bdd223334..6939b5c6e 100644 --- a/iceoryx2/src/service/service_id.rs +++ b/iceoryx2/src/service/service_id.rs @@ -26,7 +26,9 @@ use super::{messaging_pattern::MessagingPattern, service_name::ServiceName}; const SERVICE_ID_CAPACITY: usize = 64; /// The unique id of a [`Service`](crate::service::Service) -#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash, ZeroCopySend, Serialize, Deserialize)] +#[derive( + Debug, Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, ZeroCopySend, Serialize, Deserialize, +)] #[repr(C)] pub struct ServiceId(pub(crate) RestrictedFileName); diff --git a/iceoryx2/src/waitset.rs b/iceoryx2/src/waitset.rs index 40a7b4126..8e61aa904 100644 --- a/iceoryx2/src/waitset.rs +++ b/iceoryx2/src/waitset.rs @@ -142,11 +142,11 @@ //! # } //! ``` //! -//! ## [`HashMap`](std::collections::HashMap) approach +//! ## [`BTreeMap`](std::collections::BTreeMap) approach //! //! ```no_run //! use iceoryx2::prelude::*; -//! use std::collections::HashMap; +//! use std::collections::BTreeMap; //! use iceoryx2::port::listener::Listener; //! # use core::time::Duration; //! # fn main() -> Result<(), Box> { @@ -161,7 +161,7 @@ //! let listener_1 = event_1.listener_builder().create()?; //! let listener_2 = event_2.listener_builder().create()?; //! -//! let mut listeners: HashMap, &Listener> = HashMap::new(); +//! let mut listeners: BTreeMap, &Listener> = BTreeMap::new(); //! let waitset = WaitSetBuilder::new().create::()?; //! //! // attach all listeners to the waitset @@ -218,10 +218,10 @@ use core::{ time::Duration, }; +use alloc::collections::BTreeMap; use alloc::vec; use alloc::vec::Vec; -use iceoryx2_bb_container::hash_map::HashMap; use iceoryx2_bb_elementary::CallbackProgression; use iceoryx2_bb_log::fail; use iceoryx2_bb_posix::{ @@ -507,8 +507,8 @@ impl WaitSetBuilder { Ok(reactor) => Ok(WaitSet { reactor, deadline_queue, - attachment_to_deadline: RefCell::new(HashMap::new()), - deadline_to_attachment: RefCell::new(HashMap::new()), + attachment_to_deadline: RefCell::new(BTreeMap::new()), + deadline_to_attachment: RefCell::new(BTreeMap::new()), attachment_counter: IoxAtomicUsize::new(0), signal_handling_mode: self.signal_handling_mode, }), @@ -539,8 +539,8 @@ impl WaitSetBuilder { pub struct WaitSet { reactor: Service::Reactor, deadline_queue: DeadlineQueue, - attachment_to_deadline: RefCell>, - deadline_to_attachment: RefCell>, + attachment_to_deadline: RefCell>, + deadline_to_attachment: RefCell>, attachment_counter: IoxAtomicUsize, signal_handling_mode: SignalHandlingMode, } From bf5a66f0d099d8429b8d48a64c99932c166de18d Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Mon, 20 Oct 2025 07:24:15 +0200 Subject: [PATCH 20/30] [#865] Do not use logger for application output in examples --- examples/rust/blackboard/BUILD.bazel | 2 -- examples/rust/blackboard/creator.rs | 9 ++++----- examples/rust/blackboard/opener.rs | 9 ++++----- .../BUILD.bazel | 2 -- .../creator.rs | 9 ++++----- .../opener.rs | 5 ++--- examples/rust/complex_data_types/BUILD.bazel | 1 - .../complex_data_types/complex_data_types.rs | 5 ++--- .../BUILD.bazel | 2 -- .../publisher.rs | 5 ++--- .../subscriber.rs | 7 +++---- .../BUILD.bazel | 2 -- .../publisher.rs | 5 ++--- .../subscriber.rs | 7 +++---- .../BUILD.bazel | 2 -- .../publisher.rs | 5 ++--- .../subscriber.rs | 7 +++---- examples/rust/discovery/BUILD.bazel | 1 - examples/rust/discovery/discovery.rs | 3 +-- .../rust/discovery_service/discovery_service.rs | 8 ++++---- .../discovery_service_client.rs | 7 +++---- examples/rust/domains/BUILD.bazel | 3 --- examples/rust/domains/discovery.rs | 5 ++--- examples/rust/domains/publisher.rs | 5 ++--- examples/rust/domains/subscriber.rs | 7 +++---- examples/rust/event/BUILD.bazel | 2 -- examples/rust/event/listener.rs | 7 +++---- examples/rust/event/notifier.rs | 5 ++--- .../rust/event_based_communication/BUILD.bazel | 2 -- .../rust/event_based_communication/publisher.rs | 11 +++++------ .../event_based_communication/subscriber.rs | 17 +++++++++-------- examples/rust/event_multiplexing/BUILD.bazel | 2 -- examples/rust/event_multiplexing/notifier.rs | 5 ++--- examples/rust/event_multiplexing/wait.rs | 7 +++---- examples/rust/health_monitoring/BUILD.bazel | 4 ---- .../rust/health_monitoring/central_daemon.rs | 5 ++--- examples/rust/health_monitoring/publisher_1.rs | 5 ++--- examples/rust/health_monitoring/publisher_2.rs | 5 ++--- examples/rust/health_monitoring/subscriber.rs | 17 +++++++++-------- examples/rust/publish_subscribe/BUILD.bazel | 2 -- examples/rust/publish_subscribe/publisher.rs | 5 ++--- examples/rust/publish_subscribe/subscriber.rs | 7 +++---- .../publish_subscribe_dynamic_data/BUILD.bazel | 2 -- .../publish_subscribe_dynamic_data/publisher.rs | 5 ++--- .../subscriber.rs | 7 +++---- .../BUILD.bazel | 2 -- .../publisher.rs | 5 ++--- .../subscriber.rs | 7 +++---- examples/rust/request_response/BUILD.bazel | 2 -- examples/rust/request_response/client.rs | 9 ++++----- examples/rust/request_response/server.rs | 11 +++++------ .../request_response_dynamic_data/BUILD.bazel | 2 -- .../request_response_dynamic_data/client.rs | 7 +++---- .../request_response_dynamic_data/server.rs | 9 ++++----- examples/rust/service_attributes/BUILD.bazel | 3 --- examples/rust/service_attributes/creator.rs | 5 ++--- .../rust/service_attributes/incompatible.rs | 5 ++--- examples/rust/service_attributes/opener.rs | 7 +++---- examples/rust/service_types/BUILD.bazel | 3 --- examples/rust/service_types/ipc_publisher.rs | 5 ++--- .../service_types/ipc_threadsafe_subscriber.rs | 7 +++---- examples/rust/service_types/local_pubsub.rs | 7 +++---- 62 files changed, 131 insertions(+), 210 deletions(-) diff --git a/examples/rust/blackboard/BUILD.bazel b/examples/rust/blackboard/BUILD.bazel index 719e3f5a3..dae5d7059 100644 --- a/examples/rust/blackboard/BUILD.bazel +++ b/examples/rust/blackboard/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], @@ -32,7 +31,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], diff --git a/examples/rust/blackboard/creator.rs b/examples/rust/blackboard/creator.rs index 5b8a7e8be..45b3cb440 100644 --- a/examples/rust/blackboard/creator.rs +++ b/examples/rust/blackboard/creator.rs @@ -18,7 +18,6 @@ use alloc::format; use examples_common::BlackboardKey; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -36,7 +35,7 @@ fn main() -> Result<(), Box> { .add::(key_1, INITIAL_VALUE_1) .create()?; - info!("Blackboard created.\n"); + println!("Blackboard created.\n"); let writer = service.writer_builder().create()?; @@ -49,16 +48,16 @@ fn main() -> Result<(), Box> { counter += 1; entry_handle_mut_0.update_with_copy(counter); - info!("Write new value for key 0: {counter}"); + println!("Write new value for key 0: {counter}"); let entry_value_uninit = entry_handle_mut_1.loan_uninit(); let value = INITIAL_VALUE_1 * counter as f64; let entry_value = entry_value_uninit.write(value); entry_handle_mut_1 = entry_value.update(); - info!("Write new value for key 1: {}\n", value); + println!("Write new value for key 1: {}\n", value); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/blackboard/opener.rs b/examples/rust/blackboard/opener.rs index 3521c347e..5a594350b 100644 --- a/examples/rust/blackboard/opener.rs +++ b/examples/rust/blackboard/opener.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::BlackboardKey; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -38,13 +37,13 @@ fn main() -> Result<(), Box> { let entry_handle_1 = reader.entry::(&key_1)?; while node.wait(CYCLE_TIME).is_ok() { - info!("read values:"); + println!("read values:"); - info!("key: 0, value: {}", entry_handle_0.get()); - info!("key: 1, value: {}\n", entry_handle_1.get()); + println!("key: 0, value: {}", entry_handle_0.get()); + println!("key: 1, value: {}\n", entry_handle_1.get()); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/blackboard_event_based_communication/BUILD.bazel b/examples/rust/blackboard_event_based_communication/BUILD.bazel index 358d7fe35..64aa14dc4 100644 --- a/examples/rust/blackboard_event_based_communication/BUILD.bazel +++ b/examples/rust/blackboard_event_based_communication/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", ], ) diff --git a/examples/rust/blackboard_event_based_communication/creator.rs b/examples/rust/blackboard_event_based_communication/creator.rs index 966a59abe..8ca001e3e 100644 --- a/examples/rust/blackboard_event_based_communication/creator.rs +++ b/examples/rust/blackboard_event_based_communication/creator.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -33,7 +32,7 @@ fn main() -> Result<(), Box> { .add_with_default::(INTERESTING_KEY) .create()?; - info!("Blackboard created.\n"); + println!("Blackboard created.\n"); let event_service = node .service_builder(&"My/Funk/ServiceName".try_into()?) @@ -55,17 +54,17 @@ fn main() -> Result<(), Box> { counter += 1; interesting_entry_handle_mut.update_with_copy(counter); notifier.notify_with_custom_event_id(interesting_entry_id)?; - info!( + println!( "Trigger event with entry id {}", interesting_entry_id.as_value() ); entry_handle_mut.update_with_copy(2 * counter); notifier.notify_with_custom_event_id(entry_id)?; - info!("Trigger event with entry id {}", entry_id.as_value()); + println!("Trigger event with entry id {}", entry_id.as_value()); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/blackboard_event_based_communication/opener.rs b/examples/rust/blackboard_event_based_communication/opener.rs index 4961800dc..f02c2bf9b 100644 --- a/examples/rust/blackboard_event_based_communication/opener.rs +++ b/examples/rust/blackboard_event_based_communication/opener.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -44,7 +43,7 @@ fn main() -> Result<(), Box> { while node.wait(Duration::ZERO).is_ok() { if let Ok(Some(id)) = listener.timed_wait_one(CYCLE_TIME) { if id == entry_handle.entry_id() { - info!( + println!( "read: {} for entry id {}", entry_handle.get(), id.as_value() @@ -53,7 +52,7 @@ fn main() -> Result<(), Box> { } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/complex_data_types/BUILD.bazel b/examples/rust/complex_data_types/BUILD.bazel index 16346784d..a6451aa64 100644 --- a/examples/rust/complex_data_types/BUILD.bazel +++ b/examples/rust/complex_data_types/BUILD.bazel @@ -22,7 +22,6 @@ rust_binary( "//iceoryx2-bb/container:iceoryx2-bb-container", "//iceoryx2-bb/elementary:iceoryx2-bb-elementary", "//iceoryx2-bb/elementary-traits:iceoryx2-bb-elementary-traits", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], proc_macro_deps = [ "//iceoryx2-bb/derive-macros:iceoryx2-bb-derive-macros", diff --git a/examples/rust/complex_data_types/complex_data_types.rs b/examples/rust/complex_data_types/complex_data_types.rs index 6a7ec79f6..89349bd00 100644 --- a/examples/rust/complex_data_types/complex_data_types.rs +++ b/examples/rust/complex_data_types/complex_data_types.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::{queue::FixedSizeQueue, string::*, vector::*}; -use iceoryx2_bb_log::info; // For both data types we derive from PlacementDefault to allow in memory initialization // without any copy. Avoids stack overflows when data type is larger than the available stack. @@ -83,11 +82,11 @@ fn main() -> Result<(), Box> { .push(StaticString::from_bytes(b"buh")?); sample.send()?; - info!("{counter} :: send"); + println!("{counter} :: send"); // receive sample and print it while let Some(sample) = subscriber.receive()? { - info!( + println!( "{} :: received: {:?}", counter, sample.payload().plain_old_data diff --git a/examples/rust/cross_language_communication_basics/BUILD.bazel b/examples/rust/cross_language_communication_basics/BUILD.bazel index 3efb91f16..117662a15 100644 --- a/examples/rust/cross_language_communication_basics/BUILD.bazel +++ b/examples/rust/cross_language_communication_basics/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_basics/publisher.rs b/examples/rust/cross_language_communication_basics/publisher.rs index aa776014c..a555db92f 100644 --- a/examples/rust/cross_language_communication_basics/publisher.rs +++ b/examples/rust/cross_language_communication_basics/publisher.rs @@ -18,7 +18,6 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -50,10 +49,10 @@ fn main() -> Result<(), Box> { sample.send()?; - info!("Send sample {counter} ..."); + println!("Send sample {counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_basics/subscriber.rs b/examples/rust/cross_language_communication_basics/subscriber.rs index dac009bd7..234b42222 100644 --- a/examples/rust/cross_language_communication_basics/subscriber.rs +++ b/examples/rust/cross_language_communication_basics/subscriber.rs @@ -18,7 +18,6 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -34,11 +33,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("Subscriber ready to receive data!"); + println!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!( + println!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -46,7 +45,7 @@ fn main() -> Result<(), Box> { } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_complex_types/BUILD.bazel b/examples/rust/cross_language_communication_complex_types/BUILD.bazel index 2809f2b0c..555e2bd61 100644 --- a/examples/rust/cross_language_communication_complex_types/BUILD.bazel +++ b/examples/rust/cross_language_communication_complex_types/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], @@ -33,7 +32,6 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_complex_types/publisher.rs b/examples/rust/cross_language_communication_complex_types/publisher.rs index 64ed914a1..195d9f79b 100644 --- a/examples/rust/cross_language_communication_complex_types/publisher.rs +++ b/examples/rust/cross_language_communication_complex_types/publisher.rs @@ -21,7 +21,6 @@ use examples_common::FullName; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -57,10 +56,10 @@ fn main() -> Result<(), Box> { sample.send()?; - info!("Send sample {counter} ..."); + println!("Send sample {counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_complex_types/subscriber.rs b/examples/rust/cross_language_communication_complex_types/subscriber.rs index 2f77db00b..6d8fb9cb4 100644 --- a/examples/rust/cross_language_communication_complex_types/subscriber.rs +++ b/examples/rust/cross_language_communication_complex_types/subscriber.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::ComplexType; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -32,15 +31,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("Subscriber ready to receive data!"); + println!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!("received: {}", sample.some_matrix[2][5]); + println!("received: {}", sample.some_matrix[2][5]); } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_container/BUILD.bazel b/examples/rust/cross_language_communication_container/BUILD.bazel index 465facdd2..555e2bd61 100644 --- a/examples/rust/cross_language_communication_container/BUILD.bazel +++ b/examples/rust/cross_language_communication_container/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], @@ -32,7 +31,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", ], diff --git a/examples/rust/cross_language_communication_container/publisher.rs b/examples/rust/cross_language_communication_container/publisher.rs index 6f50b2c2d..6d9b8674d 100644 --- a/examples/rust/cross_language_communication_container/publisher.rs +++ b/examples/rust/cross_language_communication_container/publisher.rs @@ -18,7 +18,6 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -54,10 +53,10 @@ fn main() -> Result<(), Box> { sample.send()?; - info!("Send sample {counter} ..."); + println!("Send sample {counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_container/subscriber.rs b/examples/rust/cross_language_communication_container/subscriber.rs index 77ae5becb..a8c53f9c7 100644 --- a/examples/rust/cross_language_communication_container/subscriber.rs +++ b/examples/rust/cross_language_communication_container/subscriber.rs @@ -18,7 +18,6 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -39,11 +38,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("Subscriber ready to receive data!"); + println!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!( + println!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -51,7 +50,7 @@ fn main() -> Result<(), Box> { } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/discovery/BUILD.bazel b/examples/rust/discovery/BUILD.bazel index 1bfda8e9c..d7a2831fe 100644 --- a/examples/rust/discovery/BUILD.bazel +++ b/examples/rust/discovery/BUILD.bazel @@ -19,6 +19,5 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/discovery/discovery.rs b/examples/rust/discovery/discovery.rs index 6d44e97fd..304cee698 100644 --- a/examples/rust/discovery/discovery.rs +++ b/examples/rust/discovery/discovery.rs @@ -14,12 +14,11 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); ipc::Service::list(Config::global_config(), |service| { - info!("\n{:#?}", &service); + println!("\n{:#?}", &service); CallbackProgression::Continue })?; diff --git a/examples/rust/discovery_service/discovery_service.rs b/examples/rust/discovery_service/discovery_service.rs index edaaec5e0..99f3274d2 100644 --- a/examples/rust/discovery_service/discovery_service.rs +++ b/examples/rust/discovery_service/discovery_service.rs @@ -14,7 +14,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{error, info}; +use iceoryx2_bb_log::error; use iceoryx2_services_discovery::*; use service_discovery::Discovery; @@ -46,7 +46,7 @@ fn main() -> Result<(), Box> { let guard = waitset.attach_notification(&listener)?; let attachment = WaitSetAttachmentId::from_guard(&guard); - info!("Discovery service ready!"); + println!("Discovery service ready!"); let on_event = |attachment_id: WaitSetAttachmentId| { if attachment_id == attachment { @@ -57,10 +57,10 @@ fn main() -> Result<(), Box> { while let Ok(Some(sample)) = subscriber.receive() { match sample.payload() { Discovery::Added(details) => { - info!("Added: {:?}", details.name()); + println!("Added: {:?}", details.name()); } Discovery::Removed(details) => { - info!("Removed: {:?}", details.name()); + println!("Removed: {:?}", details.name()); } } } diff --git a/examples/rust/discovery_service/discovery_service_client.rs b/examples/rust/discovery_service/discovery_service_client.rs index 2f6d83576..74713e2c0 100644 --- a/examples/rust/discovery_service/discovery_service_client.rs +++ b/examples/rust/discovery_service/discovery_service_client.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::{prelude::*, service::static_config::StaticConfig}; -use iceoryx2_bb_log::info; use iceoryx2_services_discovery::service_discovery::service_name; const CYCLE_TIME: Duration = Duration::from_millis(10); @@ -41,10 +40,10 @@ fn main() -> Result<(), Box> { if attachment_id.has_event_from(&guard) { while let Some(response) = pending_response.receive().unwrap() { for service in response.payload().iter() { - info!("Service ID: {:?}", service.service_id().as_str()); - info!("Service Name: {:?}", service.name().as_str()); + println!("Service ID: {:?}", service.service_id().as_str()); + println!("Service Name: {:?}", service.name().as_str()); } - info!("exit"); + println!("exit"); return CallbackProgression::Stop; } } diff --git a/examples/rust/domains/BUILD.bazel b/examples/rust/domains/BUILD.bazel index 473a23ac0..3d2f78199 100644 --- a/examples/rust/domains/BUILD.bazel +++ b/examples/rust/domains/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "@crate_index//:clap", ], @@ -32,7 +31,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "//examples/rust:examples-common", "@crate_index//:clap", @@ -46,7 +44,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "//examples/rust:examples-common", "@crate_index//:clap", diff --git a/examples/rust/domains/discovery.rs b/examples/rust/domains/discovery.rs index a7088e309..269085ef5 100644 --- a/examples/rust/domains/discovery.rs +++ b/examples/rust/domains/discovery.rs @@ -16,7 +16,6 @@ use alloc::string::String; use clap::Parser; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{info, set_log_level, LogLevel}; fn main() -> Result<(), Box> { let args = parse_args(); @@ -28,11 +27,11 @@ fn main() -> Result<(), Box> { // Therefore, different domain names never share the same resources. config.global.prefix = FileName::new(args.domain.as_bytes())?; - info!("\nServices running in domain \"{}\":", args.domain); + println!("\nServices running in domain \"{}\":", args.domain); // use the custom config when listing the services ipc::Service::list(&config, |service| { - info!(" {}", &service.static_details.name()); + println!(" {}", &service.static_details.name()); CallbackProgression::Continue })?; diff --git a/examples/rust/domains/publisher.rs b/examples/rust/domains/publisher.rs index 7478d6f73..7bbc1eac0 100644 --- a/examples/rust/domains/publisher.rs +++ b/examples/rust/domains/publisher.rs @@ -21,7 +21,6 @@ use clap::Parser; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{info, set_log_level, LogLevel}; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -65,13 +64,13 @@ fn main() -> Result<(), Box> { sample.send()?; - info!( + println!( "[domain: \"{}\", service: \"{}\"] Send sample {} ...", args.domain, args.service, counter ); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/domains/subscriber.rs b/examples/rust/domains/subscriber.rs index a386b4b2d..0618ea92c 100644 --- a/examples/rust/domains/subscriber.rs +++ b/examples/rust/domains/subscriber.rs @@ -21,7 +21,6 @@ use clap::Parser; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::{info, set_log_level, LogLevel}; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -48,17 +47,17 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!( + println!( "subscribed to: [domain: \"{}\", service: \"{}\"]", args.domain, args.service ); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!("received: {:?}", *sample); + println!("received: {:?}", *sample); } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/event/BUILD.bazel b/examples/rust/event/BUILD.bazel index 029fdf0d5..526049f29 100644 --- a/examples/rust/event/BUILD.bazel +++ b/examples/rust/event/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -30,6 +29,5 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/event/listener.rs b/examples/rust/event/listener.rs index 9e5aa4569..fcf677307 100644 --- a/examples/rust/event/listener.rs +++ b/examples/rust/event/listener.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -31,15 +30,15 @@ fn main() -> Result<(), Box> { let listener = event.listener_builder().create()?; - info!("Listener ready to receive events!"); + println!("Listener ready to receive events!"); while node.wait(Duration::ZERO).is_ok() { if let Ok(Some(event_id)) = listener.timed_wait_one(CYCLE_TIME) { - info!("event was triggered with id: {event_id:?}"); + println!("event was triggered with id: {event_id:?}"); } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/event/notifier.rs b/examples/rust/event/notifier.rs index 775167354..7c96c9789 100644 --- a/examples/rust/event/notifier.rs +++ b/examples/rust/event/notifier.rs @@ -13,7 +13,6 @@ use core::time::Duration; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -34,10 +33,10 @@ fn main() -> Result<(), Box> { counter += 1; notifier.notify_with_custom_event_id(EventId::new(counter % max_event_id))?; - info!("Trigger event with id {counter} ..."); + println!("Trigger event with id {counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/event_based_communication/BUILD.bazel b/examples/rust/event_based_communication/BUILD.bazel index 3efb91f16..117662a15 100644 --- a/examples/rust/event_based_communication/BUILD.bazel +++ b/examples/rust/event_based_communication/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/event_based_communication/publisher.rs b/examples/rust/event_based_communication/publisher.rs index 8c9683359..5d3755f31 100644 --- a/examples/rust/event_based_communication/publisher.rs +++ b/examples/rust/event_based_communication/publisher.rs @@ -23,7 +23,6 @@ use iceoryx2::{ }, prelude::*, }; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); const HISTORY_SIZE: usize = 20; @@ -46,7 +45,7 @@ fn main() -> Result<(), Box> { let on_event = |attachment_id: WaitSetAttachmentId| { // when the cyclic trigger guard gets notified we send out a new message if attachment_id.has_event_from(&cyclic_trigger_guard) { - info!("send message: {counter}"); + println!("send message: {counter}"); publisher.send(counter).unwrap(); counter += 1; // when something else happens on the publisher we handle the events @@ -60,7 +59,7 @@ fn main() -> Result<(), Box> { // event callback or an interrupt/termination signal was received. waitset.wait_and_process(on_event)?; - info!("exit"); + println!("exit"); Ok(()) } @@ -117,17 +116,17 @@ impl CustomPublisher { let event: PubSubEvent = event.into(); match event { PubSubEvent::SubscriberConnected => { - info!("new subscriber connected - delivering history"); + println!("new subscriber connected - delivering history"); self.publisher.update_connections().unwrap(); self.notifier .notify_with_custom_event_id(PubSubEvent::SentHistory.into()) .unwrap(); } PubSubEvent::SubscriberDisconnected => { - info!("subscriber disconnected"); + println!("subscriber disconnected"); } PubSubEvent::ReceivedSample => { - info!("subscriber has consumed sample"); + println!("subscriber has consumed sample"); } _ => (), } diff --git a/examples/rust/event_based_communication/subscriber.rs b/examples/rust/event_based_communication/subscriber.rs index 9e9d6060f..46563fbf3 100644 --- a/examples/rust/event_based_communication/subscriber.rs +++ b/examples/rust/event_based_communication/subscriber.rs @@ -21,7 +21,6 @@ use iceoryx2::{ prelude::*, sample::Sample, }; -use iceoryx2_bb_log::info; const HISTORY_SIZE: usize = 20; const DEADLINE: Duration = Duration::from_secs(2); @@ -45,7 +44,9 @@ fn main() -> Result<(), Box> { // If the subscriber did not receive an event until DEADLINE has // passed, we print out a warning. } else if attachment_id.has_missed_deadline(&subscriber_guard) { - info!("Contract violation! The subscriber did not receive a message for {DEADLINE:?}."); + println!( + "Contract violation! The subscriber did not receive a message for {DEADLINE:?}." + ); } CallbackProgression::Continue @@ -53,7 +54,7 @@ fn main() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - info!("exit"); + println!("exit"); Ok(()) } @@ -113,18 +114,18 @@ impl CustomSubscriber { let event: PubSubEvent = event.into(); match event { PubSubEvent::SentHistory => { - info!("History delivered"); + println!("History delivered"); while let Ok(Some(sample)) = self.receive() { - info!(" history: {:?}", sample.x); + println!(" history: {:?}", sample.x); } } PubSubEvent::SentSample => { while let Ok(Some(sample)) = self.receive() { - info!("received: {:?}", sample.x); + println!("received: {:?}", sample.x); } } - PubSubEvent::PublisherConnected => info!("new publisher connected"), - PubSubEvent::PublisherDisconnected => info!("publisher disconnected"), + PubSubEvent::PublisherConnected => println!("new publisher connected"), + PubSubEvent::PublisherDisconnected => println!("publisher disconnected"), _ => (), } } diff --git a/examples/rust/event_multiplexing/BUILD.bazel b/examples/rust/event_multiplexing/BUILD.bazel index 581c7e204..87c60cc7b 100644 --- a/examples/rust/event_multiplexing/BUILD.bazel +++ b/examples/rust/event_multiplexing/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", "@crate_index//:clap", ], @@ -32,7 +31,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", "@crate_index//:clap", diff --git a/examples/rust/event_multiplexing/notifier.rs b/examples/rust/event_multiplexing/notifier.rs index 027c71a5c..100b237f0 100644 --- a/examples/rust/event_multiplexing/notifier.rs +++ b/examples/rust/event_multiplexing/notifier.rs @@ -18,7 +18,6 @@ use alloc::string::String; use clap::Parser; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -37,10 +36,10 @@ fn main() -> Result<(), Box> { while node.wait(CYCLE_TIME).is_ok() { notifier.notify_with_custom_event_id(EventId::new(args.event_id))?; - info!("[service: \"{}\"] Trigger event ...", args.service); + println!("[service: \"{}\"] Trigger event ...", args.service); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/event_multiplexing/wait.rs b/examples/rust/event_multiplexing/wait.rs index de8287bda..c429e079f 100644 --- a/examples/rust/event_multiplexing/wait.rs +++ b/examples/rust/event_multiplexing/wait.rs @@ -18,7 +18,6 @@ use alloc::vec; use alloc::vec::Vec; use iceoryx2::{port::listener::Listener, prelude::*}; -use iceoryx2_bb_log::info; use clap::Parser; @@ -59,7 +58,7 @@ fn main() -> Result<(), Box> { guards.push(guard); } - info!("Waiting on the following services: {:?}", args.services); + println!("Waiting on the following services: {:?}", args.services); // the callback that is called when a listener has received an event let on_event = |attachment_id: WaitSetAttachmentId| { @@ -70,7 +69,7 @@ fn main() -> Result<(), Box> { // busy loop. listener .try_wait_all(|event_id| { - info!("Received trigger from \"{service_name}\" :: {event_id:?}"); + println!("Received trigger from \"{service_name}\" :: {event_id:?}"); }) .unwrap(); } @@ -83,7 +82,7 @@ fn main() -> Result<(), Box> { // didn't add this to the example so feel free to play around with it. waitset.wait_and_process(on_event)?; - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/BUILD.bazel b/examples/rust/health_monitoring/BUILD.bazel index b0094b571..a0ed206db 100644 --- a/examples/rust/health_monitoring/BUILD.bazel +++ b/examples/rust/health_monitoring/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -43,7 +41,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -55,7 +52,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/health_monitoring/central_daemon.rs b/examples/rust/health_monitoring/central_daemon.rs index 43e5585bd..fd2b37e2f 100644 --- a/examples/rust/health_monitoring/central_daemon.rs +++ b/examples/rust/health_monitoring/central_daemon.rs @@ -18,7 +18,6 @@ use alloc::boxed::Box; use examples_common::PubSubEvent; use iceoryx2::node::NodeView; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(100); const DEADLINE_SERVICE_1: Duration = Duration::from_millis(1500); @@ -78,7 +77,7 @@ fn main() -> Result<(), Box> { let waitset = WaitSetBuilder::new().create::()?; let _cycle_guard = waitset.attach_interval(CYCLE_TIME); - info!("Central daemon up and running."); + println!("Central daemon up and running."); waitset.wait_and_process(|_| { // The only task of our central daemon is it to monitor all running nodes and cleanup their // resources if a process has died. @@ -96,7 +95,7 @@ fn main() -> Result<(), Box> { fn find_and_cleanup_dead_nodes() { Node::::list(Config::global_config(), |node_state| { if let NodeState::Dead(state) = node_state { - info!( + println!( "detected dead node: {:?}", state.details().as_ref().map(|v| v.name()) ); diff --git a/examples/rust/health_monitoring/publisher_1.rs b/examples/rust/health_monitoring/publisher_1.rs index eff850c8d..0d5323921 100644 --- a/examples/rust/health_monitoring/publisher_1.rs +++ b/examples/rust/health_monitoring/publisher_1.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(1000); @@ -46,7 +45,7 @@ fn main() -> Result<(), Box> { let _cycle_guard = waitset.attach_interval(CYCLE_TIME); waitset.wait_and_process(|_| { - info!("{service_name}: Send sample {counter} ..."); + println!("{service_name}: Send sample {counter} ..."); publisher .send_copy(counter) .expect("sample delivery successful."); @@ -55,7 +54,7 @@ fn main() -> Result<(), Box> { CallbackProgression::Continue })?; - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/publisher_2.rs b/examples/rust/health_monitoring/publisher_2.rs index eb661bc4b..9d5e206bc 100644 --- a/examples/rust/health_monitoring/publisher_2.rs +++ b/examples/rust/health_monitoring/publisher_2.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(1500); @@ -46,7 +45,7 @@ fn main() -> Result<(), Box> { let _cycle_guard = waitset.attach_interval(CYCLE_TIME); waitset.wait_and_process(|_| { - info!("{service_name}: Send sample {counter} ..."); + println!("{service_name}: Send sample {counter} ..."); publisher .send_copy(counter) .expect("sample delivery successful."); @@ -55,7 +54,7 @@ fn main() -> Result<(), Box> { CallbackProgression::Continue })?; - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/subscriber.rs b/examples/rust/health_monitoring/subscriber.rs index 9a2f40481..dad7f71ed 100644 --- a/examples/rust/health_monitoring/subscriber.rs +++ b/examples/rust/health_monitoring/subscriber.rs @@ -21,7 +21,6 @@ use iceoryx2::{ port::{listener::Listener, subscriber::Subscriber}, prelude::*, }; -use iceoryx2_bb_log::info; const REACTION_BUFFER_MS: u64 = 500; const CYCLE_TIME_1: Duration = Duration::from_millis(1000 + REACTION_BUFFER_MS); @@ -54,7 +53,9 @@ fn main() -> Result<(), Box> { let listener_2_guard = waitset.attach_deadline(&listener_2, deadline_2)?; let missed_deadline = |service_name, cycle_time| { - info!("{service_name}: violated contract and did not send a message after {cycle_time:?}."); + println!( + "{service_name}: violated contract and did not send a message after {cycle_time:?}." + ); }; let on_event = |attachment_id: WaitSetAttachmentId| { @@ -86,7 +87,7 @@ fn main() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - info!("exit"); + println!("exit"); Ok(()) } @@ -94,7 +95,7 @@ fn main() -> Result<(), Box> { fn find_and_cleanup_dead_nodes() { Node::::list(Config::global_config(), |node_state| { if let NodeState::Dead(state) = node_state { - info!( + println!( "detected dead node: {:?}", state.details().as_ref().map(|v| v.name()) ); @@ -114,14 +115,14 @@ fn handle_incoming_event( listener .try_wait_all(|event_id| { if event_id == PubSubEvent::ProcessDied.into() { - info!("{service_name}: process died!"); + println!("{service_name}: process died!"); } else if event_id == PubSubEvent::PublisherConnected.into() { - info!("{service_name}: publisher connected!"); + println!("{service_name}: publisher connected!"); } else if event_id == PubSubEvent::PublisherDisconnected.into() { - info!("{service_name}: publisher disconnected!"); + println!("{service_name}: publisher disconnected!"); } else if event_id == PubSubEvent::SentSample.into() { if let Some(sample) = subscriber.receive().expect("") { - info!("{}: Received sample {} ...", service_name, *sample) + println!("{}: Received sample {} ...", service_name, *sample) } } }) diff --git a/examples/rust/publish_subscribe/BUILD.bazel b/examples/rust/publish_subscribe/BUILD.bazel index 3efb91f16..117662a15 100644 --- a/examples/rust/publish_subscribe/BUILD.bazel +++ b/examples/rust/publish_subscribe/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe/publisher.rs b/examples/rust/publish_subscribe/publisher.rs index dd8cba070..9d56c3218 100644 --- a/examples/rust/publish_subscribe/publisher.rs +++ b/examples/rust/publish_subscribe/publisher.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -46,10 +45,10 @@ fn main() -> Result<(), Box> { sample.send()?; - info!("Send sample {counter} ..."); + println!("Send sample {counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe/subscriber.rs b/examples/rust/publish_subscribe/subscriber.rs index 15d134035..570fb26af 100644 --- a/examples/rust/publish_subscribe/subscriber.rs +++ b/examples/rust/publish_subscribe/subscriber.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -32,15 +31,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("Subscriber ready to receive data!"); + println!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!("received: {:?}", *sample); + println!("received: {:?}", *sample); } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel b/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel index 3efb91f16..117662a15 100644 --- a/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel +++ b/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe_dynamic_data/publisher.rs b/examples/rust/publish_subscribe_dynamic_data/publisher.rs index 4d83929e5..a85e92799 100644 --- a/examples/rust/publish_subscribe_dynamic_data/publisher.rs +++ b/examples/rust/publish_subscribe_dynamic_data/publisher.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -50,12 +49,12 @@ fn main() -> Result<(), Box> { sample.send()?; - info!("Send sample {counter} with {required_memory_size} bytes..."); + println!("Send sample {counter} with {required_memory_size} bytes..."); counter += 1; } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs index 54e0517b9..928652815 100644 --- a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs +++ b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -31,15 +30,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("Subscriber ready to receive data!"); + println!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!("received {} bytes", sample.payload().len()); + println!("received {} bytes", sample.payload().len()); } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_with_user_header/BUILD.bazel b/examples/rust/publish_subscribe_with_user_header/BUILD.bazel index 3efb91f16..117662a15 100644 --- a/examples/rust/publish_subscribe_with_user_header/BUILD.bazel +++ b/examples/rust/publish_subscribe_with_user_header/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe_with_user_header/publisher.rs b/examples/rust/publish_subscribe_with_user_header/publisher.rs index 942281b43..d0c33f9f2 100644 --- a/examples/rust/publish_subscribe_with_user_header/publisher.rs +++ b/examples/rust/publish_subscribe_with_user_header/publisher.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -49,10 +48,10 @@ fn main() -> Result<(), Box> { sample.send()?; - info!("Send sample {counter} ..."); + println!("Send sample {counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_with_user_header/subscriber.rs b/examples/rust/publish_subscribe_with_user_header/subscriber.rs index fa999e065..b7fa43b3f 100644 --- a/examples/rust/publish_subscribe_with_user_header/subscriber.rs +++ b/examples/rust/publish_subscribe_with_user_header/subscriber.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -33,11 +32,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("Subscriber ready to receive data!"); + println!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!( + println!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -45,7 +44,7 @@ fn main() -> Result<(), Box> { } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/request_response/BUILD.bazel b/examples/rust/request_response/BUILD.bazel index 4ae7561f0..ac064f398 100644 --- a/examples/rust/request_response/BUILD.bazel +++ b/examples/rust/request_response/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/request_response/client.rs b/examples/rust/request_response/client.rs index 4a06b16f5..7c09f08aa 100644 --- a/examples/rust/request_response/client.rs +++ b/examples/rust/request_response/client.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -36,13 +35,13 @@ fn main() -> Result<(), Box> { let mut response_counter: u64 = 0; // sending first request by using slower, inefficient copy API - info!("send request {request_counter} ..."); + println!("send request {request_counter} ..."); let mut pending_response = client.send_copy(request_counter)?; while node.wait(CYCLE_TIME).is_ok() { // acquire all responses to our request from our buffer that were sent by the servers while let Some(response) = pending_response.receive()? { - info!(" received response {response_counter}: {:?}", *response); + println!(" received response {response_counter}: {:?}", *response); response_counter += 1; } @@ -53,10 +52,10 @@ fn main() -> Result<(), Box> { pending_response = request.send()?; - info!("send request {request_counter} ..."); + println!("send request {request_counter} ..."); } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/request_response/server.rs b/examples/rust/request_response/server.rs index bb38b6313..d0b778d96 100644 --- a/examples/rust/request_response/server.rs +++ b/examples/rust/request_response/server.rs @@ -17,7 +17,6 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(100); @@ -32,19 +31,19 @@ fn main() -> Result<(), Box> { let server = service.server_builder().create()?; - info!("Server ready to receive requests!"); + println!("Server ready to receive requests!"); let mut counter = 0; while node.wait(CYCLE_TIME).is_ok() { while let Some(active_request) = server.receive()? { - info!("received request: {:?}", *active_request); + println!("received request: {:?}", *active_request); let response = TransmissionData { x: 5 + counter, y: 6 * counter, funky: 7.77, }; - info!(" send response: {response:?}"); + println!(" send response: {response:?}"); // send first response by using the slower, non-zero-copy API active_request.send_copy(response)?; @@ -56,7 +55,7 @@ fn main() -> Result<(), Box> { y: counter + n as i32, funky: counter as f64 * 0.1234, }); - info!(" send response: {:?}", *response); + println!(" send response: {:?}", *response); response.send()?; } @@ -69,7 +68,7 @@ fn main() -> Result<(), Box> { counter += 1; } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/request_response_dynamic_data/BUILD.bazel b/examples/rust/request_response_dynamic_data/BUILD.bazel index 4ae7561f0..ac064f398 100644 --- a/examples/rust/request_response_dynamic_data/BUILD.bazel +++ b/examples/rust/request_response_dynamic_data/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -31,7 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/request_response_dynamic_data/client.rs b/examples/rust/request_response_dynamic_data/client.rs index 665d1a3ba..bed4e57b7 100644 --- a/examples/rust/request_response_dynamic_data/client.rs +++ b/examples/rust/request_response_dynamic_data/client.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -49,7 +48,7 @@ fn main() -> Result<(), Box> { let request = request.write_from_fn(|byte_idx| ((byte_idx + counter) % 255) as u8); let pending_response = request.send()?; - info!("send request {counter} with {required_memory_size} bytes ..."); + println!("send request {counter} with {required_memory_size} bytes ..."); if node.wait(CYCLE_TIME).is_err() { break; @@ -57,7 +56,7 @@ fn main() -> Result<(), Box> { // acquire all responses to our request from our buffer that were sent by the servers while let Some(response) = pending_response.receive()? { - info!( + println!( " received response with {} bytes", response.payload().len() ); @@ -66,7 +65,7 @@ fn main() -> Result<(), Box> { counter += 1; } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/request_response_dynamic_data/server.rs b/examples/rust/request_response_dynamic_data/server.rs index f690baad0..932c57251 100644 --- a/examples/rust/request_response_dynamic_data/server.rs +++ b/examples/rust/request_response_dynamic_data/server.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(100); @@ -41,12 +40,12 @@ fn main() -> Result<(), Box> { .allocation_strategy(AllocationStrategy::PowerOfTwo) .create()?; - info!("Server ready to receive requests!"); + println!("Server ready to receive requests!"); let mut counter = 1; while node.wait(CYCLE_TIME).is_ok() { while let Some(active_request) = server.receive()? { - info!( + println!( "received request with {} bytes ...", active_request.payload().len() ); @@ -54,14 +53,14 @@ fn main() -> Result<(), Box> { let required_memory_size = 1_000_000.min(counter * counter); let response = active_request.loan_slice_uninit(required_memory_size)?; let response = response.write_from_fn(|byte_idx| ((byte_idx + counter) % 255) as u8); - info!(" send response with {} bytes", response.payload().len()); + println!(" send response with {} bytes", response.payload().len()); response.send()?; } counter += 1; } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/service_attributes/BUILD.bazel b/examples/rust/service_attributes/BUILD.bazel index d688bd5b2..3ee4f5687 100644 --- a/examples/rust/service_attributes/BUILD.bazel +++ b/examples/rust/service_attributes/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -30,7 +29,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -41,6 +39,5 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/service_attributes/creator.rs b/examples/rust/service_attributes/creator.rs index 731b64075..687045017 100644 --- a/examples/rust/service_attributes/creator.rs +++ b/examples/rust/service_attributes/creator.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -42,7 +41,7 @@ fn main() -> Result<(), Box> { let publisher = service.publisher_builder().create()?; - info!("defined service attributes: {:?}", service.attributes()); + println!("defined service attributes: {:?}", service.attributes()); while node.wait(CYCLE_TIME).is_ok() { let sample = publisher.loan_uninit()?; @@ -50,7 +49,7 @@ fn main() -> Result<(), Box> { sample.send()?; } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/service_attributes/incompatible.rs b/examples/rust/service_attributes/incompatible.rs index d2e1604fb..5a3807e1b 100644 --- a/examples/rust/service_attributes/incompatible.rs +++ b/examples/rust/service_attributes/incompatible.rs @@ -14,7 +14,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); @@ -29,7 +28,7 @@ fn main() -> Result<(), Box> { &AttributeVerifier::new() .require(&"camera_resolution".try_into()?, &"3840x2160".try_into()?)?, ) - .map_err(|e| info!("camera_resolution: 3840x2160 -> {:?}", e)); + .map_err(|e| println!("camera_resolution: 3840x2160 -> {:?}", e)); let _incompatible_service = node .service_builder(&"Service/With/Properties".try_into()?) @@ -38,7 +37,7 @@ fn main() -> Result<(), Box> { // the opening of the service will fail since the key is not defined. &AttributeVerifier::new().require_key(&"camera_type".try_into()?)?, ) - .map_err(|e| info!("camera_type -> {:?}", e)); + .map_err(|e| println!("camera_type -> {:?}", e)); Ok(()) } diff --git a/examples/rust/service_attributes/opener.rs b/examples/rust/service_attributes/opener.rs index 082db9beb..43d713d22 100644 --- a/examples/rust/service_attributes/opener.rs +++ b/examples/rust/service_attributes/opener.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -37,15 +36,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - info!("defined service attributes: {:?}", service.attributes()); + println!("defined service attributes: {:?}", service.attributes()); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - info!("received: {:?}", *sample); + println!("received: {:?}", *sample); } } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/service_types/BUILD.bazel b/examples/rust/service_types/BUILD.bazel index 4dddb4011..825baf98e 100644 --- a/examples/rust/service_types/BUILD.bazel +++ b/examples/rust/service_types/BUILD.bazel @@ -19,7 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -30,7 +29,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/posix:iceoryx2-bb-posix", ], ) @@ -42,7 +40,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", - "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/posix:iceoryx2-bb-posix", ], ) diff --git a/examples/rust/service_types/ipc_publisher.rs b/examples/rust/service_types/ipc_publisher.rs index b6640a367..e6d3b3a71 100644 --- a/examples/rust/service_types/ipc_publisher.rs +++ b/examples/rust/service_types/ipc_publisher.rs @@ -16,7 +16,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; const CYCLE_TIME: Duration = Duration::from_millis(750); @@ -41,12 +40,12 @@ fn main() -> Result<(), Box> { let mut counter = 0u64; while node.wait(CYCLE_TIME).is_ok() { - info!("send: {counter}"); + println!("send: {counter}"); publisher.send_copy(counter)?; counter += 1; } - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/service_types/ipc_threadsafe_subscriber.rs b/examples/rust/service_types/ipc_threadsafe_subscriber.rs index 9975268cd..90c1ee460 100644 --- a/examples/rust/service_types/ipc_threadsafe_subscriber.rs +++ b/examples/rust/service_types/ipc_threadsafe_subscriber.rs @@ -18,7 +18,6 @@ use alloc::boxed::Box; use alloc::sync::Arc; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; use iceoryx2_bb_posix::clock::nanosleep; use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; @@ -52,21 +51,21 @@ fn main() -> Result<(), Box> { while KEEP_RUNNING.load(Ordering::Relaxed) { nanosleep(CYCLE_TIME).unwrap(); if let Some(sample) = in_thread_subscriber.receive().unwrap() { - info!("[thread] received: {}", sample.payload()); + println!("[thread] received: {}", sample.payload()); } } })?; while node.wait(CYCLE_TIME).is_ok() { if let Some(sample) = subscriber.receive()? { - info!("[main] received: {}", sample.payload()); + println!("[main] received: {}", sample.payload()); } } KEEP_RUNNING.store(false, Ordering::Relaxed); drop(other_thread); - info!("exit"); + println!("exit"); Ok(()) } diff --git a/examples/rust/service_types/local_pubsub.rs b/examples/rust/service_types/local_pubsub.rs index aacfb7125..e891fe38f 100644 --- a/examples/rust/service_types/local_pubsub.rs +++ b/examples/rust/service_types/local_pubsub.rs @@ -17,7 +17,6 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::info; use iceoryx2_bb_posix::clock::nanosleep; use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; @@ -44,7 +43,7 @@ fn background_thread() { while KEEP_RUNNING.load(Ordering::Relaxed) { nanosleep(CYCLE_TIME).unwrap(); while let Some(sample) = subscriber.receive().unwrap() { - info!("[thread] received: {}", sample.payload()); + println!("[thread] received: {}", sample.payload()); } } } @@ -73,14 +72,14 @@ fn main() -> Result<(), Box> { let mut counter = 0u64; while node.wait(CYCLE_TIME).is_ok() { - info!("send: {counter}"); + println!("send: {counter}"); publisher.send_copy(counter)?; counter += 1; } KEEP_RUNNING.store(false, Ordering::Relaxed); drop(background_thread); - info!("exit"); + println!("exit"); Ok(()) } From 942efbf2d317c80dbb54eabdfda1b5532beeb225 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Mon, 20 Oct 2025 07:40:12 +0200 Subject: [PATCH 21/30] [#865] Document new logger feature flags --- iceoryx2/Cargo.toml | 4 ++-- iceoryx2/src/lib.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/iceoryx2/Cargo.toml b/iceoryx2/Cargo.toml index 65d17fc31..65ff969e9 100644 --- a/iceoryx2/Cargo.toml +++ b/iceoryx2/Cargo.toml @@ -19,12 +19,12 @@ std = [ "logger_file" ] +# Enables logging to console +logger_console = ["iceoryx2-bb-log/logger_console"] # Enables logging to buffer logger_buffer = ["iceoryx2-bb-log/logger_buffer"] # Enables logging to file logger_file = ["iceoryx2-bb-log/logger_file"] -# Enables logging to console -logger_console = ["iceoryx2-bb-log/logger_console"] # Enables https://crates.io/crates/log as default logger logger_log = [ "iceoryx2-bb-log/logger_log" diff --git a/iceoryx2/src/lib.rs b/iceoryx2/src/lib.rs index 7872cf0d6..02733d406 100644 --- a/iceoryx2/src/lib.rs +++ b/iceoryx2/src/lib.rs @@ -496,8 +496,11 @@ //! * `dev_permissions` - The permissions of all resources will be set to read, write, execute //! for everyone. This shall not be used in production and is meant to be enabled in a docker //! environment with inconsistent user configuration. -//! * `logger_log` - Uses the [log crate](https://crates.io/crates/log) as default log backend -//! * `logger_tracing` - Uses the [tracing crate](https://crates.io/crates/tracing) as default log +//! * `logger_console` - Include the [console logger](`iceoryx2_bb_log::logger::console::Logger`) and use it as the default log backend +//! * `logger_buffer` - Include the [buffer logger](`iceoryx2_bb_log::logger::buffer::Logger`), which can be set at runtime +//! * `logger_file` - Include the [file logger](`iceoryx2_bb_log::logger::file::Logger`), which can be set at runtime +//! * `logger_log` - Uses the [log crate](https://crates.io/crates/log) as the default log backend +//! * `logger_tracing` - Uses the [tracing crate](https://crates.io/crates/tracing) as the default log //! backend //! * `libc_platform` - Uses the [libc crate](https://crates.io/crates/libc) for the platform //! abstraction to simplify cross compilation. Works currently only for Linux based targets. From 5042b5257b31a8d46530f1a5d59f0cebdc6f4d66 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Mon, 20 Oct 2025 08:32:00 +0200 Subject: [PATCH 22/30] [#865] Use additional alloc components in iceoryx2-tunnel --- iceoryx2-tunnel/tunnel/src/discovery/subscriber.rs | 2 ++ iceoryx2-tunnel/tunnel/src/ports/event.rs | 1 + iceoryx2-tunnel/tunnel/src/ports/publish_subscribe.rs | 2 ++ iceoryx2-tunnel/tunnel/src/tunnel.rs | 1 + 4 files changed, 6 insertions(+) diff --git a/iceoryx2-tunnel/tunnel/src/discovery/subscriber.rs b/iceoryx2-tunnel/tunnel/src/discovery/subscriber.rs index 237826b5b..b9ceb0de0 100644 --- a/iceoryx2-tunnel/tunnel/src/discovery/subscriber.rs +++ b/iceoryx2-tunnel/tunnel/src/discovery/subscriber.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; + use iceoryx2::node::Node; use iceoryx2::prelude::ServiceName; use iceoryx2::service::static_config::StaticConfig; diff --git a/iceoryx2-tunnel/tunnel/src/ports/event.rs b/iceoryx2-tunnel/tunnel/src/ports/event.rs index d8b9d5371..14010e9f2 100644 --- a/iceoryx2-tunnel/tunnel/src/ports/event.rs +++ b/iceoryx2-tunnel/tunnel/src/ports/event.rs @@ -11,6 +11,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use alloc::collections::BTreeSet; +use alloc::format; use iceoryx2::{ node::Node, diff --git a/iceoryx2-tunnel/tunnel/src/ports/publish_subscribe.rs b/iceoryx2-tunnel/tunnel/src/ports/publish_subscribe.rs index 05e311732..0612d9922 100644 --- a/iceoryx2-tunnel/tunnel/src/ports/publish_subscribe.rs +++ b/iceoryx2-tunnel/tunnel/src/ports/publish_subscribe.rs @@ -10,6 +10,8 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT +use alloc::format; + use iceoryx2::node::{Node, NodeId}; use iceoryx2::port::LoanError; use iceoryx2::prelude::AllocationStrategy; diff --git a/iceoryx2-tunnel/tunnel/src/tunnel.rs b/iceoryx2-tunnel/tunnel/src/tunnel.rs index 5496baee1..1a410551e 100644 --- a/iceoryx2-tunnel/tunnel/src/tunnel.rs +++ b/iceoryx2-tunnel/tunnel/src/tunnel.rs @@ -14,6 +14,7 @@ use core::fmt::Debug; use alloc::collections::BTreeMap; use alloc::collections::BTreeSet; +use alloc::format; use alloc::string::String; use iceoryx2::node::{Node, NodeBuilder, NodeId}; From 47836229d09b9ea9b4c79f1ee029976ec15a69a9 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 22 Oct 2025 05:56:28 +0200 Subject: [PATCH 23/30] [#865] Keep use of eprintln! in examples --- examples/rust/discovery_service/discovery_service.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rust/discovery_service/discovery_service.rs b/examples/rust/discovery_service/discovery_service.rs index 99f3274d2..544a92499 100644 --- a/examples/rust/discovery_service/discovery_service.rs +++ b/examples/rust/discovery_service/discovery_service.rs @@ -28,7 +28,7 @@ fn main() -> Result<(), Box> { .publish_subscribe::() .open() .inspect_err(|_| { - error!("Unable to open service discovery service. Was it started?"); + eprintln!("Unable to open service discovery service. Was it started?"); })?; let subscriber = publish_subscribe.subscriber_builder().create()?; @@ -38,7 +38,7 @@ fn main() -> Result<(), Box> { .event() .open() .inspect_err(|_| { - error!("unable to open service discovery service. Was it started?"); + eprintln!("unable to open service discovery service. Was it started?"); })?; let listener = event.listener_builder().create()?; From d8866e5f16753a1d716908f23f020b9d06c9980d Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 22 Oct 2025 05:57:43 +0200 Subject: [PATCH 24/30] [#865] Remove log level arg from domain example --- examples/rust/domains/discovery.rs | 13 +------------ examples/rust/domains/publisher.rs | 13 +------------ examples/rust/domains/subscriber.rs | 13 +------------ 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/examples/rust/domains/discovery.rs b/examples/rust/domains/discovery.rs index 269085ef5..39f316c2d 100644 --- a/examples/rust/domains/discovery.rs +++ b/examples/rust/domains/discovery.rs @@ -18,6 +18,7 @@ use clap::Parser; use iceoryx2::prelude::*; fn main() -> Result<(), Box> { + set_log_level_from_env_or(LogLevel::Info); let args = parse_args(); // create a new config based on the global config @@ -49,21 +50,9 @@ struct Args { /// The name of the domain. Must be a valid file name. #[clap(short, long, default_value = "iox2")] domain: String, - /// Enable full debug log output - #[clap(long, default_value_t = false)] - debug: bool, -} - -fn define_log_level(args: &Args) { - if args.debug { - set_log_level(LogLevel::Trace); - } else { - set_log_level(LogLevel::Info); - } } fn parse_args() -> Args { let args = Args::parse(); - define_log_level(&args); args } diff --git a/examples/rust/domains/publisher.rs b/examples/rust/domains/publisher.rs index 7bbc1eac0..2ac7a32aa 100644 --- a/examples/rust/domains/publisher.rs +++ b/examples/rust/domains/publisher.rs @@ -25,6 +25,7 @@ use iceoryx2::prelude::*; const CYCLE_TIME: Duration = Duration::from_secs(1); fn main() -> Result<(), Box> { + set_log_level_from_env_or(LogLevel::Info); let args = parse_args(); // create a new config based on the global config @@ -89,21 +90,9 @@ struct Args { /// The name of the service. #[clap(short, long, default_value = "my_funky_service")] service: String, - /// Enable full debug log output - #[clap(long, default_value_t = false)] - debug: bool, -} - -fn define_log_level(args: &Args) { - if args.debug { - set_log_level(LogLevel::Trace); - } else { - set_log_level(LogLevel::Info); - } } fn parse_args() -> Args { let args = Args::parse(); - define_log_level(&args); args } diff --git a/examples/rust/domains/subscriber.rs b/examples/rust/domains/subscriber.rs index 0618ea92c..1401f5631 100644 --- a/examples/rust/domains/subscriber.rs +++ b/examples/rust/domains/subscriber.rs @@ -25,6 +25,7 @@ use iceoryx2::prelude::*; const CYCLE_TIME: Duration = Duration::from_secs(1); fn main() -> Result<(), Box> { + set_log_level_from_env_or(LogLevel::Info); let args = parse_args(); // create a new config based on the global config @@ -76,21 +77,9 @@ struct Args { /// The of the service. #[clap(short, long, default_value = "my_funky_service")] service: String, - /// Enable full debug log output - #[clap(long, default_value_t = false)] - debug: bool, -} - -fn define_log_level(args: &Args) { - if args.debug { - set_log_level(LogLevel::Trace); - } else { - set_log_level(LogLevel::Info); - } } fn parse_args() -> Args { let args = Args::parse(); - define_log_level(&args); args } From ea66ca45e1e7a092fa793d19c0ed83d33b62f387 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 22 Oct 2025 06:19:46 +0200 Subject: [PATCH 25/30] [#865] Preserve order of operations when removing registered services --- iceoryx2/src/node/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index f81350856..ed8051b05 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -802,14 +802,15 @@ impl RegisteredServices { entry.1 -= 1; if entry.1 == 0 { let handle = entry.0; - guard.remove(service_id); - drop(guard); cleanup_call(handle); + guard.remove(service_id); } } else { fatal_panic!(from "RegisteredServices::remove()", "This should never happen! The service with the {:?} was not registered.", service_id); } + + drop(guard); } fn mutex(&self) -> Mutex<'_, '_, BTreeMap> { From a781167136949b7e10b57cf1fb5ad4ed5958a9a0 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 22 Oct 2025 06:29:44 +0200 Subject: [PATCH 26/30] [#865] Use std::sync::Once when std feature is enabled --- iceoryx2-bb/log/src/lib.rs | 7 ++++++- iceoryx2-ffi/c/src/api/log.rs | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index 9d2cb765d..000255414 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -168,7 +168,12 @@ pub mod logger; #[cfg(feature = "std")] pub use from_env::{set_log_level_from_env_or, set_log_level_from_env_or_default}; -use iceoryx2_pal_concurrency_sync::{iox_atomic::IoxAtomicU8, once::Once}; +use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU8; + +#[cfg(not(feature = "std"))] +use iceoryx2_pal_concurrency_sync::once::Once; +#[cfg(feature = "std")] +use std::sync::Once; use core::{fmt::Arguments, sync::atomic::Ordering}; diff --git a/iceoryx2-ffi/c/src/api/log.rs b/iceoryx2-ffi/c/src/api/log.rs index c2dc0c573..1190ae229 100644 --- a/iceoryx2-ffi/c/src/api/log.rs +++ b/iceoryx2-ffi/c/src/api/log.rs @@ -23,7 +23,10 @@ use iceoryx2_bb_log::{ get_log_level, set_log_level, set_logger, Log, LogLevel, __internal_print_log_msg, }; +#[cfg(not(feature = "std"))] use iceoryx2_pal_concurrency_sync::once::Once; +#[cfg(feature = "std")] +use std::sync::Once; #[repr(C)] #[derive(Copy, Clone)] From 5d7fd75460083514f12e3d62ad7d7678fb07af17 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 22 Oct 2025 10:16:29 +0200 Subject: [PATCH 27/30] [#865] Add wrapper for println and eprintln --- examples/rust/blackboard/BUILD.bazel | 2 + examples/rust/blackboard/creator.rs | 2 +- examples/rust/blackboard/opener.rs | 1 + .../BUILD.bazel | 2 + .../creator.rs | 1 + .../opener.rs | 1 + examples/rust/complex_data_types/BUILD.bazel | 1 + .../complex_data_types/complex_data_types.rs | 1 + .../BUILD.bazel | 2 + .../publisher.rs | 1 + .../subscriber.rs | 1 + .../BUILD.bazel | 2 + .../publisher.rs | 1 + .../subscriber.rs | 1 + .../BUILD.bazel | 2 + .../publisher.rs | 1 + .../subscriber.rs | 1 + examples/rust/discovery/BUILD.bazel | 1 + examples/rust/discovery/discovery.rs | 1 + .../discovery_service/discovery_service.rs | 3 +- .../discovery_service_client.rs | 1 + examples/rust/domains/BUILD.bazel | 3 ++ examples/rust/domains/discovery.rs | 1 + examples/rust/domains/publisher.rs | 1 + examples/rust/domains/subscriber.rs | 1 + examples/rust/event/BUILD.bazel | 2 + examples/rust/event/listener.rs | 1 + examples/rust/event/notifier.rs | 1 + .../event_based_communication/BUILD.bazel | 2 + .../event_based_communication/publisher.rs | 1 + .../event_based_communication/subscriber.rs | 1 + examples/rust/event_multiplexing/BUILD.bazel | 2 + examples/rust/event_multiplexing/notifier.rs | 1 + examples/rust/event_multiplexing/wait.rs | 1 + examples/rust/health_monitoring/BUILD.bazel | 4 ++ .../rust/health_monitoring/central_daemon.rs | 1 + .../rust/health_monitoring/publisher_1.rs | 1 + .../rust/health_monitoring/publisher_2.rs | 1 + examples/rust/health_monitoring/subscriber.rs | 1 + examples/rust/publish_subscribe/BUILD.bazel | 2 + examples/rust/publish_subscribe/publisher.rs | 1 + examples/rust/publish_subscribe/subscriber.rs | 1 + .../BUILD.bazel | 2 + .../publisher.rs | 1 + .../subscriber.rs | 1 + .../BUILD.bazel | 2 + .../publisher.rs | 1 + .../subscriber.rs | 1 + examples/rust/request_response/BUILD.bazel | 2 + examples/rust/request_response/client.rs | 1 + examples/rust/request_response/server.rs | 1 + .../request_response_dynamic_data/BUILD.bazel | 2 + .../request_response_dynamic_data/client.rs | 1 + .../request_response_dynamic_data/server.rs | 1 + examples/rust/service_attributes/BUILD.bazel | 3 ++ examples/rust/service_attributes/creator.rs | 1 + .../rust/service_attributes/incompatible.rs | 1 + examples/rust/service_attributes/opener.rs | 1 + examples/rust/service_types/BUILD.bazel | 3 ++ examples/rust/service_types/ipc_publisher.rs | 1 + .../ipc_threadsafe_subscriber.rs | 1 + examples/rust/service_types/local_pubsub.rs | 1 + iceoryx2-bb/log/src/lib.rs | 27 +++++++++++++ iceoryx2-bb/posix/src/config.rs | 40 +++++++++---------- 64 files changed, 132 insertions(+), 22 deletions(-) diff --git a/examples/rust/blackboard/BUILD.bazel b/examples/rust/blackboard/BUILD.bazel index dae5d7059..cdbd1655f 100644 --- a/examples/rust/blackboard/BUILD.bazel +++ b/examples/rust/blackboard/BUILD.bazel @@ -21,6 +21,7 @@ rust_binary( "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -33,5 +34,6 @@ rust_binary( "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/blackboard/creator.rs b/examples/rust/blackboard/creator.rs index 45b3cb440..6036827c5 100644 --- a/examples/rust/blackboard/creator.rs +++ b/examples/rust/blackboard/creator.rs @@ -14,10 +14,10 @@ use core::time::Duration; extern crate alloc; use alloc::boxed::Box; -use alloc::format; use examples_common::BlackboardKey; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/blackboard/opener.rs b/examples/rust/blackboard/opener.rs index 5a594350b..cb325c86b 100644 --- a/examples/rust/blackboard/opener.rs +++ b/examples/rust/blackboard/opener.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::BlackboardKey; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/blackboard_event_based_communication/BUILD.bazel b/examples/rust/blackboard_event_based_communication/BUILD.bazel index 64aa14dc4..e38f62773 100644 --- a/examples/rust/blackboard_event_based_communication/BUILD.bazel +++ b/examples/rust/blackboard_event_based_communication/BUILD.bazel @@ -20,6 +20,7 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -31,5 +32,6 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/blackboard_event_based_communication/creator.rs b/examples/rust/blackboard_event_based_communication/creator.rs index 8ca001e3e..01a0ed4b9 100644 --- a/examples/rust/blackboard_event_based_communication/creator.rs +++ b/examples/rust/blackboard_event_based_communication/creator.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/blackboard_event_based_communication/opener.rs b/examples/rust/blackboard_event_based_communication/opener.rs index f02c2bf9b..a0a29eb1d 100644 --- a/examples/rust/blackboard_event_based_communication/opener.rs +++ b/examples/rust/blackboard_event_based_communication/opener.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/complex_data_types/BUILD.bazel b/examples/rust/complex_data_types/BUILD.bazel index a6451aa64..16346784d 100644 --- a/examples/rust/complex_data_types/BUILD.bazel +++ b/examples/rust/complex_data_types/BUILD.bazel @@ -22,6 +22,7 @@ rust_binary( "//iceoryx2-bb/container:iceoryx2-bb-container", "//iceoryx2-bb/elementary:iceoryx2-bb-elementary", "//iceoryx2-bb/elementary-traits:iceoryx2-bb-elementary-traits", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], proc_macro_deps = [ "//iceoryx2-bb/derive-macros:iceoryx2-bb-derive-macros", diff --git a/examples/rust/complex_data_types/complex_data_types.rs b/examples/rust/complex_data_types/complex_data_types.rs index 89349bd00..bff3c25b2 100644 --- a/examples/rust/complex_data_types/complex_data_types.rs +++ b/examples/rust/complex_data_types/complex_data_types.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::{queue::FixedSizeQueue, string::*, vector::*}; +use iceoryx2_bb_log::println; // For both data types we derive from PlacementDefault to allow in memory initialization // without any copy. Avoids stack overflows when data type is larger than the available stack. diff --git a/examples/rust/cross_language_communication_basics/BUILD.bazel b/examples/rust/cross_language_communication_basics/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/cross_language_communication_basics/BUILD.bazel +++ b/examples/rust/cross_language_communication_basics/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_basics/publisher.rs b/examples/rust/cross_language_communication_basics/publisher.rs index a555db92f..365d5204e 100644 --- a/examples/rust/cross_language_communication_basics/publisher.rs +++ b/examples/rust/cross_language_communication_basics/publisher.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/cross_language_communication_basics/subscriber.rs b/examples/rust/cross_language_communication_basics/subscriber.rs index 234b42222..da3a665f4 100644 --- a/examples/rust/cross_language_communication_basics/subscriber.rs +++ b/examples/rust/cross_language_communication_basics/subscriber.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/cross_language_communication_complex_types/BUILD.bazel b/examples/rust/cross_language_communication_complex_types/BUILD.bazel index 555e2bd61..0d5262f51 100644 --- a/examples/rust/cross_language_communication_complex_types/BUILD.bazel +++ b/examples/rust/cross_language_communication_complex_types/BUILD.bazel @@ -20,6 +20,7 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -32,6 +33,7 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_complex_types/publisher.rs b/examples/rust/cross_language_communication_complex_types/publisher.rs index 195d9f79b..ae1abb022 100644 --- a/examples/rust/cross_language_communication_complex_types/publisher.rs +++ b/examples/rust/cross_language_communication_complex_types/publisher.rs @@ -21,6 +21,7 @@ use examples_common::FullName; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/cross_language_communication_complex_types/subscriber.rs b/examples/rust/cross_language_communication_complex_types/subscriber.rs index 6d8fb9cb4..e3867fbe7 100644 --- a/examples/rust/cross_language_communication_complex_types/subscriber.rs +++ b/examples/rust/cross_language_communication_complex_types/subscriber.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::ComplexType; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/cross_language_communication_container/BUILD.bazel b/examples/rust/cross_language_communication_container/BUILD.bazel index 555e2bd61..0d5262f51 100644 --- a/examples/rust/cross_language_communication_container/BUILD.bazel +++ b/examples/rust/cross_language_communication_container/BUILD.bazel @@ -20,6 +20,7 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -32,6 +33,7 @@ rust_binary( deps = [ "//iceoryx2:iceoryx2", "//iceoryx2-bb/container:iceoryx2-bb-container", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/cross_language_communication_container/publisher.rs b/examples/rust/cross_language_communication_container/publisher.rs index 6d9b8674d..893612dea 100644 --- a/examples/rust/cross_language_communication_container/publisher.rs +++ b/examples/rust/cross_language_communication_container/publisher.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/cross_language_communication_container/subscriber.rs b/examples/rust/cross_language_communication_container/subscriber.rs index a8c53f9c7..e5edf61f7 100644 --- a/examples/rust/cross_language_communication_container/subscriber.rs +++ b/examples/rust/cross_language_communication_container/subscriber.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/discovery/BUILD.bazel b/examples/rust/discovery/BUILD.bazel index d7a2831fe..1bfda8e9c 100644 --- a/examples/rust/discovery/BUILD.bazel +++ b/examples/rust/discovery/BUILD.bazel @@ -19,5 +19,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/discovery/discovery.rs b/examples/rust/discovery/discovery.rs index 304cee698..f31be12c7 100644 --- a/examples/rust/discovery/discovery.rs +++ b/examples/rust/discovery/discovery.rs @@ -14,6 +14,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); diff --git a/examples/rust/discovery_service/discovery_service.rs b/examples/rust/discovery_service/discovery_service.rs index 544a92499..ab03757d4 100644 --- a/examples/rust/discovery_service/discovery_service.rs +++ b/examples/rust/discovery_service/discovery_service.rs @@ -14,7 +14,8 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::error; +use iceoryx2_bb_log::eprintln; +use iceoryx2_bb_log::println; use iceoryx2_services_discovery::*; use service_discovery::Discovery; diff --git a/examples/rust/discovery_service/discovery_service_client.rs b/examples/rust/discovery_service/discovery_service_client.rs index 74713e2c0..736f661ba 100644 --- a/examples/rust/discovery_service/discovery_service_client.rs +++ b/examples/rust/discovery_service/discovery_service_client.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::{prelude::*, service::static_config::StaticConfig}; +use iceoryx2_bb_log::println; use iceoryx2_services_discovery::service_discovery::service_name; const CYCLE_TIME: Duration = Duration::from_millis(10); diff --git a/examples/rust/domains/BUILD.bazel b/examples/rust/domains/BUILD.bazel index 3d2f78199..473a23ac0 100644 --- a/examples/rust/domains/BUILD.bazel +++ b/examples/rust/domains/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "@crate_index//:clap", ], @@ -31,6 +32,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "//examples/rust:examples-common", "@crate_index//:clap", @@ -44,6 +46,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/system-types:iceoryx2-bb-system-types", "//examples/rust:examples-common", "@crate_index//:clap", diff --git a/examples/rust/domains/discovery.rs b/examples/rust/domains/discovery.rs index 39f316c2d..d76d0efcb 100644 --- a/examples/rust/domains/discovery.rs +++ b/examples/rust/domains/discovery.rs @@ -16,6 +16,7 @@ use alloc::string::String; use clap::Parser; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); diff --git a/examples/rust/domains/publisher.rs b/examples/rust/domains/publisher.rs index 2ac7a32aa..c24d09eb6 100644 --- a/examples/rust/domains/publisher.rs +++ b/examples/rust/domains/publisher.rs @@ -21,6 +21,7 @@ use clap::Parser; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/domains/subscriber.rs b/examples/rust/domains/subscriber.rs index 1401f5631..c89bbbf6b 100644 --- a/examples/rust/domains/subscriber.rs +++ b/examples/rust/domains/subscriber.rs @@ -21,6 +21,7 @@ use clap::Parser; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/event/BUILD.bazel b/examples/rust/event/BUILD.bazel index 526049f29..029fdf0d5 100644 --- a/examples/rust/event/BUILD.bazel +++ b/examples/rust/event/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -29,5 +30,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/event/listener.rs b/examples/rust/event/listener.rs index fcf677307..7a262b142 100644 --- a/examples/rust/event/listener.rs +++ b/examples/rust/event/listener.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/event/notifier.rs b/examples/rust/event/notifier.rs index 7c96c9789..a9e5f4189 100644 --- a/examples/rust/event/notifier.rs +++ b/examples/rust/event/notifier.rs @@ -13,6 +13,7 @@ use core::time::Duration; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/event_based_communication/BUILD.bazel b/examples/rust/event_based_communication/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/event_based_communication/BUILD.bazel +++ b/examples/rust/event_based_communication/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/event_based_communication/publisher.rs b/examples/rust/event_based_communication/publisher.rs index 5d3755f31..c0001d826 100644 --- a/examples/rust/event_based_communication/publisher.rs +++ b/examples/rust/event_based_communication/publisher.rs @@ -23,6 +23,7 @@ use iceoryx2::{ }, prelude::*, }; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); const HISTORY_SIZE: usize = 20; diff --git a/examples/rust/event_based_communication/subscriber.rs b/examples/rust/event_based_communication/subscriber.rs index 46563fbf3..03d8e112e 100644 --- a/examples/rust/event_based_communication/subscriber.rs +++ b/examples/rust/event_based_communication/subscriber.rs @@ -21,6 +21,7 @@ use iceoryx2::{ prelude::*, sample::Sample, }; +use iceoryx2_bb_log::println; const HISTORY_SIZE: usize = 20; const DEADLINE: Duration = Duration::from_secs(2); diff --git a/examples/rust/event_multiplexing/BUILD.bazel b/examples/rust/event_multiplexing/BUILD.bazel index 87c60cc7b..581c7e204 100644 --- a/examples/rust/event_multiplexing/BUILD.bazel +++ b/examples/rust/event_multiplexing/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", "@crate_index//:clap", ], @@ -31,6 +32,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/container:iceoryx2-bb-container", "//examples/rust:examples-common", "@crate_index//:clap", diff --git a/examples/rust/event_multiplexing/notifier.rs b/examples/rust/event_multiplexing/notifier.rs index 100b237f0..f808ae956 100644 --- a/examples/rust/event_multiplexing/notifier.rs +++ b/examples/rust/event_multiplexing/notifier.rs @@ -18,6 +18,7 @@ use alloc::string::String; use clap::Parser; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/event_multiplexing/wait.rs b/examples/rust/event_multiplexing/wait.rs index c429e079f..5bd0e5f9e 100644 --- a/examples/rust/event_multiplexing/wait.rs +++ b/examples/rust/event_multiplexing/wait.rs @@ -18,6 +18,7 @@ use alloc::vec; use alloc::vec::Vec; use iceoryx2::{port::listener::Listener, prelude::*}; +use iceoryx2_bb_log::println; use clap::Parser; diff --git a/examples/rust/health_monitoring/BUILD.bazel b/examples/rust/health_monitoring/BUILD.bazel index a0ed206db..b0094b571 100644 --- a/examples/rust/health_monitoring/BUILD.bazel +++ b/examples/rust/health_monitoring/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -41,6 +43,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -52,6 +55,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/health_monitoring/central_daemon.rs b/examples/rust/health_monitoring/central_daemon.rs index fd2b37e2f..311223305 100644 --- a/examples/rust/health_monitoring/central_daemon.rs +++ b/examples/rust/health_monitoring/central_daemon.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use examples_common::PubSubEvent; use iceoryx2::node::NodeView; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_millis(100); const DEADLINE_SERVICE_1: Duration = Duration::from_millis(1500); diff --git a/examples/rust/health_monitoring/publisher_1.rs b/examples/rust/health_monitoring/publisher_1.rs index 0d5323921..8dd06d24a 100644 --- a/examples/rust/health_monitoring/publisher_1.rs +++ b/examples/rust/health_monitoring/publisher_1.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_millis(1000); diff --git a/examples/rust/health_monitoring/publisher_2.rs b/examples/rust/health_monitoring/publisher_2.rs index 9d5e206bc..509991169 100644 --- a/examples/rust/health_monitoring/publisher_2.rs +++ b/examples/rust/health_monitoring/publisher_2.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_millis(1500); diff --git a/examples/rust/health_monitoring/subscriber.rs b/examples/rust/health_monitoring/subscriber.rs index dad7f71ed..92b9dbffc 100644 --- a/examples/rust/health_monitoring/subscriber.rs +++ b/examples/rust/health_monitoring/subscriber.rs @@ -21,6 +21,7 @@ use iceoryx2::{ port::{listener::Listener, subscriber::Subscriber}, prelude::*, }; +use iceoryx2_bb_log::println; const REACTION_BUFFER_MS: u64 = 500; const CYCLE_TIME_1: Duration = Duration::from_millis(1000 + REACTION_BUFFER_MS); diff --git a/examples/rust/publish_subscribe/BUILD.bazel b/examples/rust/publish_subscribe/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/publish_subscribe/BUILD.bazel +++ b/examples/rust/publish_subscribe/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe/publisher.rs b/examples/rust/publish_subscribe/publisher.rs index 9d56c3218..4a4df78b5 100644 --- a/examples/rust/publish_subscribe/publisher.rs +++ b/examples/rust/publish_subscribe/publisher.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/publish_subscribe/subscriber.rs b/examples/rust/publish_subscribe/subscriber.rs index 570fb26af..454070ee9 100644 --- a/examples/rust/publish_subscribe/subscriber.rs +++ b/examples/rust/publish_subscribe/subscriber.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel b/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel +++ b/examples/rust/publish_subscribe_dynamic_data/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe_dynamic_data/publisher.rs b/examples/rust/publish_subscribe_dynamic_data/publisher.rs index a85e92799..77e5236b1 100644 --- a/examples/rust/publish_subscribe_dynamic_data/publisher.rs +++ b/examples/rust/publish_subscribe_dynamic_data/publisher.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs index 928652815..f8f34f725 100644 --- a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs +++ b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/publish_subscribe_with_user_header/BUILD.bazel b/examples/rust/publish_subscribe_with_user_header/BUILD.bazel index 117662a15..3efb91f16 100644 --- a/examples/rust/publish_subscribe_with_user_header/BUILD.bazel +++ b/examples/rust/publish_subscribe_with_user_header/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/publish_subscribe_with_user_header/publisher.rs b/examples/rust/publish_subscribe_with_user_header/publisher.rs index d0c33f9f2..c0fd5d7cb 100644 --- a/examples/rust/publish_subscribe_with_user_header/publisher.rs +++ b/examples/rust/publish_subscribe_with_user_header/publisher.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/publish_subscribe_with_user_header/subscriber.rs b/examples/rust/publish_subscribe_with_user_header/subscriber.rs index b7fa43b3f..e5b5629ca 100644 --- a/examples/rust/publish_subscribe_with_user_header/subscriber.rs +++ b/examples/rust/publish_subscribe_with_user_header/subscriber.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/request_response/BUILD.bazel b/examples/rust/request_response/BUILD.bazel index ac064f398..4ae7561f0 100644 --- a/examples/rust/request_response/BUILD.bazel +++ b/examples/rust/request_response/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/request_response/client.rs b/examples/rust/request_response/client.rs index 7c09f08aa..cfeb1d2dd 100644 --- a/examples/rust/request_response/client.rs +++ b/examples/rust/request_response/client.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/request_response/server.rs b/examples/rust/request_response/server.rs index d0b778d96..24e2e1d78 100644 --- a/examples/rust/request_response/server.rs +++ b/examples/rust/request_response/server.rs @@ -17,6 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_millis(100); diff --git a/examples/rust/request_response_dynamic_data/BUILD.bazel b/examples/rust/request_response_dynamic_data/BUILD.bazel index ac064f398..4ae7561f0 100644 --- a/examples/rust/request_response_dynamic_data/BUILD.bazel +++ b/examples/rust/request_response_dynamic_data/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) @@ -30,6 +31,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//examples/rust:examples-common", ], ) diff --git a/examples/rust/request_response_dynamic_data/client.rs b/examples/rust/request_response_dynamic_data/client.rs index bed4e57b7..a64fd4db2 100644 --- a/examples/rust/request_response_dynamic_data/client.rs +++ b/examples/rust/request_response_dynamic_data/client.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/request_response_dynamic_data/server.rs b/examples/rust/request_response_dynamic_data/server.rs index 932c57251..1f2baae12 100644 --- a/examples/rust/request_response_dynamic_data/server.rs +++ b/examples/rust/request_response_dynamic_data/server.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_millis(100); diff --git a/examples/rust/service_attributes/BUILD.bazel b/examples/rust/service_attributes/BUILD.bazel index 3ee4f5687..d688bd5b2 100644 --- a/examples/rust/service_attributes/BUILD.bazel +++ b/examples/rust/service_attributes/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -29,6 +30,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -39,5 +41,6 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) diff --git a/examples/rust/service_attributes/creator.rs b/examples/rust/service_attributes/creator.rs index 687045017..c19b3063f 100644 --- a/examples/rust/service_attributes/creator.rs +++ b/examples/rust/service_attributes/creator.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/service_attributes/incompatible.rs b/examples/rust/service_attributes/incompatible.rs index 5a3807e1b..e8a52e735 100644 --- a/examples/rust/service_attributes/incompatible.rs +++ b/examples/rust/service_attributes/incompatible.rs @@ -14,6 +14,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); diff --git a/examples/rust/service_attributes/opener.rs b/examples/rust/service_attributes/opener.rs index 43d713d22..52774fdf4 100644 --- a/examples/rust/service_attributes/opener.rs +++ b/examples/rust/service_attributes/opener.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_secs(1); diff --git a/examples/rust/service_types/BUILD.bazel b/examples/rust/service_types/BUILD.bazel index 825baf98e..4dddb4011 100644 --- a/examples/rust/service_types/BUILD.bazel +++ b/examples/rust/service_types/BUILD.bazel @@ -19,6 +19,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", ], ) @@ -29,6 +30,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/posix:iceoryx2-bb-posix", ], ) @@ -40,6 +42,7 @@ rust_binary( ], deps = [ "//iceoryx2:iceoryx2", + "//iceoryx2-bb/log:iceoryx2-bb-log", "//iceoryx2-bb/posix:iceoryx2-bb-posix", ], ) diff --git a/examples/rust/service_types/ipc_publisher.rs b/examples/rust/service_types/ipc_publisher.rs index e6d3b3a71..7fcb29f18 100644 --- a/examples/rust/service_types/ipc_publisher.rs +++ b/examples/rust/service_types/ipc_publisher.rs @@ -16,6 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; const CYCLE_TIME: Duration = Duration::from_millis(750); diff --git a/examples/rust/service_types/ipc_threadsafe_subscriber.rs b/examples/rust/service_types/ipc_threadsafe_subscriber.rs index 90c1ee460..b0ca1f635 100644 --- a/examples/rust/service_types/ipc_threadsafe_subscriber.rs +++ b/examples/rust/service_types/ipc_threadsafe_subscriber.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use alloc::sync::Arc; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; use iceoryx2_bb_posix::clock::nanosleep; use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; diff --git a/examples/rust/service_types/local_pubsub.rs b/examples/rust/service_types/local_pubsub.rs index e891fe38f..71367ae58 100644 --- a/examples/rust/service_types/local_pubsub.rs +++ b/examples/rust/service_types/local_pubsub.rs @@ -17,6 +17,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; +use iceoryx2_bb_log::println; use iceoryx2_bb_posix::clock::nanosleep; use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index 000255414..41dc23eb2 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -316,3 +316,30 @@ pub fn __internal_print_log_msg(log_level: LogLevel, origin: Arguments, args: Ar get_logger().log(log_level, origin, args) } } + +// TODO(#1127): Add proper printing abstraction that can be implemented for no_std platforms +#[cfg(feature = "std")] +#[macro_export] +macro_rules! println { + ($($arg:tt)*) => { + std::println!($($arg)*) + }; +} +#[cfg(feature = "std")] +#[macro_export] +macro_rules! eprintln { + ($($arg:tt)*) => { + std::eprintln!($($arg)*) + }; +} + +#[cfg(not(feature = "std"))] +#[macro_export] +macro_rules! println { + ($($arg:tt)*) => {{}}; +} +#[cfg(not(feature = "std"))] +#[macro_export] +macro_rules! eprintln { + ($($arg:tt)*) => {{}}; +} diff --git a/iceoryx2-bb/posix/src/config.rs b/iceoryx2-bb/posix/src/config.rs index 6b4bb13ee..7e9843a02 100644 --- a/iceoryx2-bb/posix/src/config.rs +++ b/iceoryx2-bb/posix/src/config.rs @@ -17,7 +17,7 @@ use core::time::Duration; use alloc::{format, string::ToString}; -use iceoryx2_bb_log::info; +use iceoryx2_bb_log::println; use iceoryx2_bb_system_types::{file_name::FileName, path::Path, user_name::UserName}; use crate::{scheduler::Scheduler, system_configuration::*}; @@ -112,9 +112,9 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool let mut is_compliant: bool = true; if mode == ComplianceCheckMode::Verbose { - info!("{HEADER_COLOR}system requirements check{COLOR_RESET}"); - info!(""); - info!(" {HEADER_COLOR}minimum system{COLOR_RESET}"); + println!("{HEADER_COLOR}system requirements check{COLOR_RESET}"); + println!(""); + println!(" {HEADER_COLOR}minimum system{COLOR_RESET}"); } for i in MIN_REQUIRED_SYSTEM.iter() { let supported_value = i.0.value(); @@ -128,7 +128,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - info!( + println!( " {}{:<40}{} minimum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -144,8 +144,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - info!(""); - info!(" {HEADER_COLOR}maximum system{COLOR_RESET}"); + println!(""); + println!(" {HEADER_COLOR}maximum system{COLOR_RESET}"); } for i in MAX_REQUIRED_SYSTEM.iter() { let supported_value = i.0.value(); @@ -159,7 +159,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - info!( + println!( " {}{:<40}{} maximum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -175,8 +175,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - info!(""); - info!(" {HEADER_COLOR}minimum limits{COLOR_RESET}"); + println!(""); + println!(" {HEADER_COLOR}minimum limits{COLOR_RESET}"); } for i in MIN_REQUIRED_LIMITS.iter() { let supported_value = i.0.value(); @@ -197,7 +197,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - info!( + println!( " {}{:<40}{} minimum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -213,8 +213,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - info!(""); - info!(" {HEADER_COLOR}maximum limits{COLOR_RESET}"); + println!(""); + println!(" {HEADER_COLOR}maximum limits{COLOR_RESET}"); } for i in MAX_REQUIRED_LIMITS.iter() { let supported_value = i.0.value(); @@ -235,7 +235,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - info!( + println!( " {}{:<40}{} maximum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -251,8 +251,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - info!(""); - info!(" {HEADER_COLOR}features{COLOR_RESET}"); + println!(""); + println!(" {HEADER_COLOR}features{COLOR_RESET}"); } for i in REQUIRED_FEATURES.iter() { let is_supported = i.is_available(); @@ -265,7 +265,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - info!( + println!( " {}{:<40}{} required: {}{:<15}{} supported: {}{:<15}{}", entry_color, format!("{:?}", i), @@ -281,10 +281,10 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - info!(""); + println!(""); match !is_compliant { - true => info!(" {FAILED_COLOR}[ system non-compliant ]{COLOR_RESET}"), - false => info!(" [ system compliant ]"), + true => println!(" {FAILED_COLOR}[ system non-compliant ]{COLOR_RESET}"), + false => println!(" [ system compliant ]"), } } From ccb95fdab83ec8be4eded58ada5b0eed44216288 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Sat, 25 Oct 2025 18:46:18 +0900 Subject: [PATCH 28/30] [#865] Rename wrappers for println and eprintln to cout and cerr --- examples/rust/blackboard/creator.rs | 10 ++--- examples/rust/blackboard/opener.rs | 10 ++--- .../creator.rs | 10 ++--- .../opener.rs | 6 +-- .../complex_data_types/complex_data_types.rs | 6 +-- .../publisher.rs | 6 +-- .../subscriber.rs | 8 ++-- .../publisher.rs | 6 +-- .../subscriber.rs | 8 ++-- .../publisher.rs | 6 +-- .../subscriber.rs | 8 ++-- examples/rust/discovery/discovery.rs | 4 +- .../discovery_service/discovery_service.rs | 14 +++---- .../discovery_service_client.rs | 8 ++-- examples/rust/domains/discovery.rs | 6 +-- examples/rust/domains/publisher.rs | 10 +++-- examples/rust/domains/subscriber.rs | 11 ++--- examples/rust/event/listener.rs | 8 ++-- examples/rust/event/notifier.rs | 6 +-- .../event_based_communication/publisher.rs | 12 +++--- .../event_based_communication/subscriber.rs | 18 ++++----- examples/rust/event_multiplexing/notifier.rs | 6 +-- examples/rust/event_multiplexing/wait.rs | 8 ++-- .../rust/health_monitoring/central_daemon.rs | 6 +-- .../rust/health_monitoring/publisher_1.rs | 6 +-- .../rust/health_monitoring/publisher_2.rs | 6 +-- examples/rust/health_monitoring/subscriber.rs | 18 ++++----- examples/rust/publish_subscribe/publisher.rs | 6 +-- examples/rust/publish_subscribe/subscriber.rs | 8 ++-- .../publisher.rs | 6 +-- .../subscriber.rs | 8 ++-- .../publisher.rs | 6 +-- .../subscriber.rs | 8 ++-- examples/rust/request_response/client.rs | 10 ++--- examples/rust/request_response/server.rs | 12 +++--- .../request_response_dynamic_data/client.rs | 8 ++-- .../request_response_dynamic_data/server.rs | 10 ++--- examples/rust/service_attributes/creator.rs | 6 +-- .../rust/service_attributes/incompatible.rs | 6 +-- examples/rust/service_attributes/opener.rs | 8 ++-- examples/rust/service_types/ipc_publisher.rs | 6 +-- .../ipc_threadsafe_subscriber.rs | 8 ++-- examples/rust/service_types/local_pubsub.rs | 8 ++-- iceoryx2-bb/log/src/lib.rs | 8 ++-- iceoryx2-bb/posix/src/config.rs | 40 +++++++++---------- 45 files changed, 201 insertions(+), 202 deletions(-) diff --git a/examples/rust/blackboard/creator.rs b/examples/rust/blackboard/creator.rs index 6036827c5..72b1427cf 100644 --- a/examples/rust/blackboard/creator.rs +++ b/examples/rust/blackboard/creator.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::BlackboardKey; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -35,7 +35,7 @@ fn main() -> Result<(), Box> { .add::(key_1, INITIAL_VALUE_1) .create()?; - println!("Blackboard created.\n"); + cout!("Blackboard created.\n"); let writer = service.writer_builder().create()?; @@ -48,16 +48,16 @@ fn main() -> Result<(), Box> { counter += 1; entry_handle_mut_0.update_with_copy(counter); - println!("Write new value for key 0: {counter}"); + cout!("Write new value for key 0: {counter}"); let entry_value_uninit = entry_handle_mut_1.loan_uninit(); let value = INITIAL_VALUE_1 * counter as f64; let entry_value = entry_value_uninit.write(value); entry_handle_mut_1 = entry_value.update(); - println!("Write new value for key 1: {}\n", value); + cout!("Write new value for key 1: {}\n", value); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/blackboard/opener.rs b/examples/rust/blackboard/opener.rs index cb325c86b..06475f019 100644 --- a/examples/rust/blackboard/opener.rs +++ b/examples/rust/blackboard/opener.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::BlackboardKey; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -38,13 +38,13 @@ fn main() -> Result<(), Box> { let entry_handle_1 = reader.entry::(&key_1)?; while node.wait(CYCLE_TIME).is_ok() { - println!("read values:"); + cout!("read values:"); - println!("key: 0, value: {}", entry_handle_0.get()); - println!("key: 1, value: {}\n", entry_handle_1.get()); + cout!("key: 0, value: {}", entry_handle_0.get()); + cout!("key: 1, value: {}\n", entry_handle_1.get()); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/blackboard_event_based_communication/creator.rs b/examples/rust/blackboard_event_based_communication/creator.rs index 01a0ed4b9..f9cee0e79 100644 --- a/examples/rust/blackboard_event_based_communication/creator.rs +++ b/examples/rust/blackboard_event_based_communication/creator.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -33,7 +33,7 @@ fn main() -> Result<(), Box> { .add_with_default::(INTERESTING_KEY) .create()?; - println!("Blackboard created.\n"); + cout!("Blackboard created.\n"); let event_service = node .service_builder(&"My/Funk/ServiceName".try_into()?) @@ -55,17 +55,17 @@ fn main() -> Result<(), Box> { counter += 1; interesting_entry_handle_mut.update_with_copy(counter); notifier.notify_with_custom_event_id(interesting_entry_id)?; - println!( + cout!( "Trigger event with entry id {}", interesting_entry_id.as_value() ); entry_handle_mut.update_with_copy(2 * counter); notifier.notify_with_custom_event_id(entry_id)?; - println!("Trigger event with entry id {}", entry_id.as_value()); + cout!("Trigger event with entry id {}", entry_id.as_value()); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/blackboard_event_based_communication/opener.rs b/examples/rust/blackboard_event_based_communication/opener.rs index a0a29eb1d..a87a31b4f 100644 --- a/examples/rust/blackboard_event_based_communication/opener.rs +++ b/examples/rust/blackboard_event_based_communication/opener.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -44,7 +44,7 @@ fn main() -> Result<(), Box> { while node.wait(Duration::ZERO).is_ok() { if let Ok(Some(id)) = listener.timed_wait_one(CYCLE_TIME) { if id == entry_handle.entry_id() { - println!( + cout!( "read: {} for entry id {}", entry_handle.get(), id.as_value() @@ -53,7 +53,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/complex_data_types/complex_data_types.rs b/examples/rust/complex_data_types/complex_data_types.rs index bff3c25b2..e7bf1df8d 100644 --- a/examples/rust/complex_data_types/complex_data_types.rs +++ b/examples/rust/complex_data_types/complex_data_types.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::{queue::FixedSizeQueue, string::*, vector::*}; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; // For both data types we derive from PlacementDefault to allow in memory initialization // without any copy. Avoids stack overflows when data type is larger than the available stack. @@ -83,11 +83,11 @@ fn main() -> Result<(), Box> { .push(StaticString::from_bytes(b"buh")?); sample.send()?; - println!("{counter} :: send"); + cout!("{counter} :: send"); // receive sample and print it while let Some(sample) = subscriber.receive()? { - println!( + cout!( "{} :: received: {:?}", counter, sample.payload().plain_old_data diff --git a/examples/rust/cross_language_communication_basics/publisher.rs b/examples/rust/cross_language_communication_basics/publisher.rs index 365d5204e..e083f131e 100644 --- a/examples/rust/cross_language_communication_basics/publisher.rs +++ b/examples/rust/cross_language_communication_basics/publisher.rs @@ -18,7 +18,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -50,10 +50,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + cout!("Send sample {counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_basics/subscriber.rs b/examples/rust/cross_language_communication_basics/subscriber.rs index da3a665f4..893c010e2 100644 --- a/examples/rust/cross_language_communication_basics/subscriber.rs +++ b/examples/rust/cross_language_communication_basics/subscriber.rs @@ -18,7 +18,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -34,11 +34,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + cout!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!( + cout!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -46,7 +46,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_complex_types/publisher.rs b/examples/rust/cross_language_communication_complex_types/publisher.rs index ae1abb022..07bd560e1 100644 --- a/examples/rust/cross_language_communication_complex_types/publisher.rs +++ b/examples/rust/cross_language_communication_complex_types/publisher.rs @@ -21,7 +21,7 @@ use examples_common::FullName; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -57,10 +57,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + cout!("Send sample {counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_complex_types/subscriber.rs b/examples/rust/cross_language_communication_complex_types/subscriber.rs index e3867fbe7..cf92fa2e7 100644 --- a/examples/rust/cross_language_communication_complex_types/subscriber.rs +++ b/examples/rust/cross_language_communication_complex_types/subscriber.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::ComplexType; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -32,15 +32,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + cout!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {}", sample.some_matrix[2][5]); + cout!("received: {}", sample.some_matrix[2][5]); } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_container/publisher.rs b/examples/rust/cross_language_communication_container/publisher.rs index 893612dea..60a05b1a0 100644 --- a/examples/rust/cross_language_communication_container/publisher.rs +++ b/examples/rust/cross_language_communication_container/publisher.rs @@ -18,7 +18,7 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -54,10 +54,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + cout!("Send sample {counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/cross_language_communication_container/subscriber.rs b/examples/rust/cross_language_communication_container/subscriber.rs index e5edf61f7..fe7ee7e31 100644 --- a/examples/rust/cross_language_communication_container/subscriber.rs +++ b/examples/rust/cross_language_communication_container/subscriber.rs @@ -18,7 +18,7 @@ use alloc::boxed::Box; use iceoryx2::prelude::*; use iceoryx2_bb_container::string::*; use iceoryx2_bb_container::vector::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -39,11 +39,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + cout!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!( + cout!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -51,7 +51,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/discovery/discovery.rs b/examples/rust/discovery/discovery.rs index f31be12c7..31f6027f3 100644 --- a/examples/rust/discovery/discovery.rs +++ b/examples/rust/discovery/discovery.rs @@ -14,12 +14,12 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); ipc::Service::list(Config::global_config(), |service| { - println!("\n{:#?}", &service); + cout!("\n{:#?}", &service); CallbackProgression::Continue })?; diff --git a/examples/rust/discovery_service/discovery_service.rs b/examples/rust/discovery_service/discovery_service.rs index ab03757d4..846d3d8f4 100644 --- a/examples/rust/discovery_service/discovery_service.rs +++ b/examples/rust/discovery_service/discovery_service.rs @@ -14,8 +14,8 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::eprintln; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cerr; +use iceoryx2_bb_log::cout; use iceoryx2_services_discovery::*; use service_discovery::Discovery; @@ -29,7 +29,7 @@ fn main() -> Result<(), Box> { .publish_subscribe::() .open() .inspect_err(|_| { - eprintln!("Unable to open service discovery service. Was it started?"); + cerr!("Unable to open service discovery service. Was it started?"); })?; let subscriber = publish_subscribe.subscriber_builder().create()?; @@ -39,7 +39,7 @@ fn main() -> Result<(), Box> { .event() .open() .inspect_err(|_| { - eprintln!("unable to open service discovery service. Was it started?"); + cerr!("unable to open service discovery service. Was it started?"); })?; let listener = event.listener_builder().create()?; @@ -47,7 +47,7 @@ fn main() -> Result<(), Box> { let guard = waitset.attach_notification(&listener)?; let attachment = WaitSetAttachmentId::from_guard(&guard); - println!("Discovery service ready!"); + cout!("Discovery service ready!"); let on_event = |attachment_id: WaitSetAttachmentId| { if attachment_id == attachment { @@ -58,10 +58,10 @@ fn main() -> Result<(), Box> { while let Ok(Some(sample)) = subscriber.receive() { match sample.payload() { Discovery::Added(details) => { - println!("Added: {:?}", details.name()); + cout!("Added: {:?}", details.name()); } Discovery::Removed(details) => { - println!("Removed: {:?}", details.name()); + cout!("Removed: {:?}", details.name()); } } } diff --git a/examples/rust/discovery_service/discovery_service_client.rs b/examples/rust/discovery_service/discovery_service_client.rs index 736f661ba..2a28acef8 100644 --- a/examples/rust/discovery_service/discovery_service_client.rs +++ b/examples/rust/discovery_service/discovery_service_client.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::{prelude::*, service::static_config::StaticConfig}; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; use iceoryx2_services_discovery::service_discovery::service_name; const CYCLE_TIME: Duration = Duration::from_millis(10); @@ -41,10 +41,10 @@ fn main() -> Result<(), Box> { if attachment_id.has_event_from(&guard) { while let Some(response) = pending_response.receive().unwrap() { for service in response.payload().iter() { - println!("Service ID: {:?}", service.service_id().as_str()); - println!("Service Name: {:?}", service.name().as_str()); + cout!("Service ID: {:?}", service.service_id().as_str()); + cout!("Service Name: {:?}", service.name().as_str()); } - println!("exit"); + cout!("exit"); return CallbackProgression::Stop; } } diff --git a/examples/rust/domains/discovery.rs b/examples/rust/domains/discovery.rs index d76d0efcb..e84b96fac 100644 --- a/examples/rust/domains/discovery.rs +++ b/examples/rust/domains/discovery.rs @@ -16,7 +16,7 @@ use alloc::string::String; use clap::Parser; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); @@ -29,11 +29,11 @@ fn main() -> Result<(), Box> { // Therefore, different domain names never share the same resources. config.global.prefix = FileName::new(args.domain.as_bytes())?; - println!("\nServices running in domain \"{}\":", args.domain); + cout!("\nServices running in domain \"{}\":", args.domain); // use the custom config when listing the services ipc::Service::list(&config, |service| { - println!(" {}", &service.static_details.name()); + cout!(" {}", &service.static_details.name()); CallbackProgression::Continue })?; diff --git a/examples/rust/domains/publisher.rs b/examples/rust/domains/publisher.rs index c24d09eb6..03f80ba09 100644 --- a/examples/rust/domains/publisher.rs +++ b/examples/rust/domains/publisher.rs @@ -21,7 +21,7 @@ use clap::Parser; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -66,13 +66,15 @@ fn main() -> Result<(), Box> { sample.send()?; - println!( + cout!( "[domain: \"{}\", service: \"{}\"] Send sample {} ...", - args.domain, args.service, counter + args.domain, + args.service, + counter ); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/domains/subscriber.rs b/examples/rust/domains/subscriber.rs index c89bbbf6b..69828f206 100644 --- a/examples/rust/domains/subscriber.rs +++ b/examples/rust/domains/subscriber.rs @@ -21,7 +21,7 @@ use clap::Parser; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -49,17 +49,18 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!( + cout!( "subscribed to: [domain: \"{}\", service: \"{}\"]", - args.domain, args.service + args.domain, + args.service ); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {:?}", *sample); + cout!("received: {:?}", *sample); } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/event/listener.rs b/examples/rust/event/listener.rs index 7a262b142..7c905eb3d 100644 --- a/examples/rust/event/listener.rs +++ b/examples/rust/event/listener.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -31,15 +31,15 @@ fn main() -> Result<(), Box> { let listener = event.listener_builder().create()?; - println!("Listener ready to receive events!"); + cout!("Listener ready to receive events!"); while node.wait(Duration::ZERO).is_ok() { if let Ok(Some(event_id)) = listener.timed_wait_one(CYCLE_TIME) { - println!("event was triggered with id: {event_id:?}"); + cout!("event was triggered with id: {event_id:?}"); } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/event/notifier.rs b/examples/rust/event/notifier.rs index a9e5f4189..2dbbe16cf 100644 --- a/examples/rust/event/notifier.rs +++ b/examples/rust/event/notifier.rs @@ -13,7 +13,7 @@ use core::time::Duration; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -34,10 +34,10 @@ fn main() -> Result<(), Box> { counter += 1; notifier.notify_with_custom_event_id(EventId::new(counter % max_event_id))?; - println!("Trigger event with id {counter} ..."); + cout!("Trigger event with id {counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/event_based_communication/publisher.rs b/examples/rust/event_based_communication/publisher.rs index c0001d826..572b1591b 100644 --- a/examples/rust/event_based_communication/publisher.rs +++ b/examples/rust/event_based_communication/publisher.rs @@ -23,7 +23,7 @@ use iceoryx2::{ }, prelude::*, }; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); const HISTORY_SIZE: usize = 20; @@ -46,7 +46,7 @@ fn main() -> Result<(), Box> { let on_event = |attachment_id: WaitSetAttachmentId| { // when the cyclic trigger guard gets notified we send out a new message if attachment_id.has_event_from(&cyclic_trigger_guard) { - println!("send message: {counter}"); + cout!("send message: {counter}"); publisher.send(counter).unwrap(); counter += 1; // when something else happens on the publisher we handle the events @@ -60,7 +60,7 @@ fn main() -> Result<(), Box> { // event callback or an interrupt/termination signal was received. waitset.wait_and_process(on_event)?; - println!("exit"); + cout!("exit"); Ok(()) } @@ -117,17 +117,17 @@ impl CustomPublisher { let event: PubSubEvent = event.into(); match event { PubSubEvent::SubscriberConnected => { - println!("new subscriber connected - delivering history"); + cout!("new subscriber connected - delivering history"); self.publisher.update_connections().unwrap(); self.notifier .notify_with_custom_event_id(PubSubEvent::SentHistory.into()) .unwrap(); } PubSubEvent::SubscriberDisconnected => { - println!("subscriber disconnected"); + cout!("subscriber disconnected"); } PubSubEvent::ReceivedSample => { - println!("subscriber has consumed sample"); + cout!("subscriber has consumed sample"); } _ => (), } diff --git a/examples/rust/event_based_communication/subscriber.rs b/examples/rust/event_based_communication/subscriber.rs index 03d8e112e..8cd161d9e 100644 --- a/examples/rust/event_based_communication/subscriber.rs +++ b/examples/rust/event_based_communication/subscriber.rs @@ -21,7 +21,7 @@ use iceoryx2::{ prelude::*, sample::Sample, }; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const HISTORY_SIZE: usize = 20; const DEADLINE: Duration = Duration::from_secs(2); @@ -45,9 +45,7 @@ fn main() -> Result<(), Box> { // If the subscriber did not receive an event until DEADLINE has // passed, we print out a warning. } else if attachment_id.has_missed_deadline(&subscriber_guard) { - println!( - "Contract violation! The subscriber did not receive a message for {DEADLINE:?}." - ); + cout!("Contract violation! The subscriber did not receive a message for {DEADLINE:?}."); } CallbackProgression::Continue @@ -55,7 +53,7 @@ fn main() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - println!("exit"); + cout!("exit"); Ok(()) } @@ -115,18 +113,18 @@ impl CustomSubscriber { let event: PubSubEvent = event.into(); match event { PubSubEvent::SentHistory => { - println!("History delivered"); + cout!("History delivered"); while let Ok(Some(sample)) = self.receive() { - println!(" history: {:?}", sample.x); + cout!(" history: {:?}", sample.x); } } PubSubEvent::SentSample => { while let Ok(Some(sample)) = self.receive() { - println!("received: {:?}", sample.x); + cout!("received: {:?}", sample.x); } } - PubSubEvent::PublisherConnected => println!("new publisher connected"), - PubSubEvent::PublisherDisconnected => println!("publisher disconnected"), + PubSubEvent::PublisherConnected => cout!("new publisher connected"), + PubSubEvent::PublisherDisconnected => cout!("publisher disconnected"), _ => (), } } diff --git a/examples/rust/event_multiplexing/notifier.rs b/examples/rust/event_multiplexing/notifier.rs index f808ae956..6a9a284b2 100644 --- a/examples/rust/event_multiplexing/notifier.rs +++ b/examples/rust/event_multiplexing/notifier.rs @@ -18,7 +18,7 @@ use alloc::string::String; use clap::Parser; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -37,10 +37,10 @@ fn main() -> Result<(), Box> { while node.wait(CYCLE_TIME).is_ok() { notifier.notify_with_custom_event_id(EventId::new(args.event_id))?; - println!("[service: \"{}\"] Trigger event ...", args.service); + cout!("[service: \"{}\"] Trigger event ...", args.service); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/event_multiplexing/wait.rs b/examples/rust/event_multiplexing/wait.rs index 5bd0e5f9e..2e00bb91a 100644 --- a/examples/rust/event_multiplexing/wait.rs +++ b/examples/rust/event_multiplexing/wait.rs @@ -18,7 +18,7 @@ use alloc::vec; use alloc::vec::Vec; use iceoryx2::{port::listener::Listener, prelude::*}; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; use clap::Parser; @@ -59,7 +59,7 @@ fn main() -> Result<(), Box> { guards.push(guard); } - println!("Waiting on the following services: {:?}", args.services); + cout!("Waiting on the following services: {:?}", args.services); // the callback that is called when a listener has received an event let on_event = |attachment_id: WaitSetAttachmentId| { @@ -70,7 +70,7 @@ fn main() -> Result<(), Box> { // busy loop. listener .try_wait_all(|event_id| { - println!("Received trigger from \"{service_name}\" :: {event_id:?}"); + cout!("Received trigger from \"{service_name}\" :: {event_id:?}"); }) .unwrap(); } @@ -83,7 +83,7 @@ fn main() -> Result<(), Box> { // didn't add this to the example so feel free to play around with it. waitset.wait_and_process(on_event)?; - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/central_daemon.rs b/examples/rust/health_monitoring/central_daemon.rs index 311223305..337bd17d5 100644 --- a/examples/rust/health_monitoring/central_daemon.rs +++ b/examples/rust/health_monitoring/central_daemon.rs @@ -18,7 +18,7 @@ use alloc::boxed::Box; use examples_common::PubSubEvent; use iceoryx2::node::NodeView; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_millis(100); const DEADLINE_SERVICE_1: Duration = Duration::from_millis(1500); @@ -78,7 +78,7 @@ fn main() -> Result<(), Box> { let waitset = WaitSetBuilder::new().create::()?; let _cycle_guard = waitset.attach_interval(CYCLE_TIME); - println!("Central daemon up and running."); + cout!("Central daemon up and running."); waitset.wait_and_process(|_| { // The only task of our central daemon is it to monitor all running nodes and cleanup their // resources if a process has died. @@ -96,7 +96,7 @@ fn main() -> Result<(), Box> { fn find_and_cleanup_dead_nodes() { Node::::list(Config::global_config(), |node_state| { if let NodeState::Dead(state) = node_state { - println!( + cout!( "detected dead node: {:?}", state.details().as_ref().map(|v| v.name()) ); diff --git a/examples/rust/health_monitoring/publisher_1.rs b/examples/rust/health_monitoring/publisher_1.rs index 8dd06d24a..1b5a492a1 100644 --- a/examples/rust/health_monitoring/publisher_1.rs +++ b/examples/rust/health_monitoring/publisher_1.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_millis(1000); @@ -46,7 +46,7 @@ fn main() -> Result<(), Box> { let _cycle_guard = waitset.attach_interval(CYCLE_TIME); waitset.wait_and_process(|_| { - println!("{service_name}: Send sample {counter} ..."); + cout!("{service_name}: Send sample {counter} ..."); publisher .send_copy(counter) .expect("sample delivery successful."); @@ -55,7 +55,7 @@ fn main() -> Result<(), Box> { CallbackProgression::Continue })?; - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/publisher_2.rs b/examples/rust/health_monitoring/publisher_2.rs index 509991169..6e853a8ed 100644 --- a/examples/rust/health_monitoring/publisher_2.rs +++ b/examples/rust/health_monitoring/publisher_2.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::{open_service, PubSubEvent}; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_millis(1500); @@ -46,7 +46,7 @@ fn main() -> Result<(), Box> { let _cycle_guard = waitset.attach_interval(CYCLE_TIME); waitset.wait_and_process(|_| { - println!("{service_name}: Send sample {counter} ..."); + cout!("{service_name}: Send sample {counter} ..."); publisher .send_copy(counter) .expect("sample delivery successful."); @@ -55,7 +55,7 @@ fn main() -> Result<(), Box> { CallbackProgression::Continue })?; - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/health_monitoring/subscriber.rs b/examples/rust/health_monitoring/subscriber.rs index 92b9dbffc..c57bb7686 100644 --- a/examples/rust/health_monitoring/subscriber.rs +++ b/examples/rust/health_monitoring/subscriber.rs @@ -21,7 +21,7 @@ use iceoryx2::{ port::{listener::Listener, subscriber::Subscriber}, prelude::*, }; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const REACTION_BUFFER_MS: u64 = 500; const CYCLE_TIME_1: Duration = Duration::from_millis(1000 + REACTION_BUFFER_MS); @@ -54,9 +54,7 @@ fn main() -> Result<(), Box> { let listener_2_guard = waitset.attach_deadline(&listener_2, deadline_2)?; let missed_deadline = |service_name, cycle_time| { - println!( - "{service_name}: violated contract and did not send a message after {cycle_time:?}." - ); + cout!("{service_name}: violated contract and did not send a message after {cycle_time:?}."); }; let on_event = |attachment_id: WaitSetAttachmentId| { @@ -88,7 +86,7 @@ fn main() -> Result<(), Box> { waitset.wait_and_process(on_event)?; - println!("exit"); + cout!("exit"); Ok(()) } @@ -96,7 +94,7 @@ fn main() -> Result<(), Box> { fn find_and_cleanup_dead_nodes() { Node::::list(Config::global_config(), |node_state| { if let NodeState::Dead(state) = node_state { - println!( + cout!( "detected dead node: {:?}", state.details().as_ref().map(|v| v.name()) ); @@ -116,14 +114,14 @@ fn handle_incoming_event( listener .try_wait_all(|event_id| { if event_id == PubSubEvent::ProcessDied.into() { - println!("{service_name}: process died!"); + cout!("{service_name}: process died!"); } else if event_id == PubSubEvent::PublisherConnected.into() { - println!("{service_name}: publisher connected!"); + cout!("{service_name}: publisher connected!"); } else if event_id == PubSubEvent::PublisherDisconnected.into() { - println!("{service_name}: publisher disconnected!"); + cout!("{service_name}: publisher disconnected!"); } else if event_id == PubSubEvent::SentSample.into() { if let Some(sample) = subscriber.receive().expect("") { - println!("{}: Received sample {} ...", service_name, *sample) + cout!("{}: Received sample {} ...", service_name, *sample) } } }) diff --git a/examples/rust/publish_subscribe/publisher.rs b/examples/rust/publish_subscribe/publisher.rs index 4a4df78b5..7fc5ff768 100644 --- a/examples/rust/publish_subscribe/publisher.rs +++ b/examples/rust/publish_subscribe/publisher.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -46,10 +46,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + cout!("Send sample {counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe/subscriber.rs b/examples/rust/publish_subscribe/subscriber.rs index 454070ee9..bbf7787bd 100644 --- a/examples/rust/publish_subscribe/subscriber.rs +++ b/examples/rust/publish_subscribe/subscriber.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -32,15 +32,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + cout!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {:?}", *sample); + cout!("received: {:?}", *sample); } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_dynamic_data/publisher.rs b/examples/rust/publish_subscribe_dynamic_data/publisher.rs index 77e5236b1..66f36cf3b 100644 --- a/examples/rust/publish_subscribe_dynamic_data/publisher.rs +++ b/examples/rust/publish_subscribe_dynamic_data/publisher.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -50,12 +50,12 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} with {required_memory_size} bytes..."); + cout!("Send sample {counter} with {required_memory_size} bytes..."); counter += 1; } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs index f8f34f725..edd1eea14 100644 --- a/examples/rust/publish_subscribe_dynamic_data/subscriber.rs +++ b/examples/rust/publish_subscribe_dynamic_data/subscriber.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -31,15 +31,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + cout!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received {} bytes", sample.payload().len()); + cout!("received {} bytes", sample.payload().len()); } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_with_user_header/publisher.rs b/examples/rust/publish_subscribe_with_user_header/publisher.rs index c0fd5d7cb..7521747fd 100644 --- a/examples/rust/publish_subscribe_with_user_header/publisher.rs +++ b/examples/rust/publish_subscribe_with_user_header/publisher.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -49,10 +49,10 @@ fn main() -> Result<(), Box> { sample.send()?; - println!("Send sample {counter} ..."); + cout!("Send sample {counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/publish_subscribe_with_user_header/subscriber.rs b/examples/rust/publish_subscribe_with_user_header/subscriber.rs index e5b5629ca..a20c1058b 100644 --- a/examples/rust/publish_subscribe_with_user_header/subscriber.rs +++ b/examples/rust/publish_subscribe_with_user_header/subscriber.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::CustomHeader; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -33,11 +33,11 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("Subscriber ready to receive data!"); + cout!("Subscriber ready to receive data!"); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!( + cout!( "received: {:?}, user_header: {:?}", *sample, sample.user_header() @@ -45,7 +45,7 @@ fn main() -> Result<(), Box> { } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/request_response/client.rs b/examples/rust/request_response/client.rs index cfeb1d2dd..f5bde2deb 100644 --- a/examples/rust/request_response/client.rs +++ b/examples/rust/request_response/client.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -36,13 +36,13 @@ fn main() -> Result<(), Box> { let mut response_counter: u64 = 0; // sending first request by using slower, inefficient copy API - println!("send request {request_counter} ..."); + cout!("send request {request_counter} ..."); let mut pending_response = client.send_copy(request_counter)?; while node.wait(CYCLE_TIME).is_ok() { // acquire all responses to our request from our buffer that were sent by the servers while let Some(response) = pending_response.receive()? { - println!(" received response {response_counter}: {:?}", *response); + cout!(" received response {response_counter}: {:?}", *response); response_counter += 1; } @@ -53,10 +53,10 @@ fn main() -> Result<(), Box> { pending_response = request.send()?; - println!("send request {request_counter} ..."); + cout!("send request {request_counter} ..."); } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/request_response/server.rs b/examples/rust/request_response/server.rs index 24e2e1d78..9b9401c0c 100644 --- a/examples/rust/request_response/server.rs +++ b/examples/rust/request_response/server.rs @@ -17,7 +17,7 @@ use alloc::boxed::Box; use examples_common::TransmissionData; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_millis(100); @@ -32,19 +32,19 @@ fn main() -> Result<(), Box> { let server = service.server_builder().create()?; - println!("Server ready to receive requests!"); + cout!("Server ready to receive requests!"); let mut counter = 0; while node.wait(CYCLE_TIME).is_ok() { while let Some(active_request) = server.receive()? { - println!("received request: {:?}", *active_request); + cout!("received request: {:?}", *active_request); let response = TransmissionData { x: 5 + counter, y: 6 * counter, funky: 7.77, }; - println!(" send response: {response:?}"); + cout!(" send response: {response:?}"); // send first response by using the slower, non-zero-copy API active_request.send_copy(response)?; @@ -56,7 +56,7 @@ fn main() -> Result<(), Box> { y: counter + n as i32, funky: counter as f64 * 0.1234, }); - println!(" send response: {:?}", *response); + cout!(" send response: {:?}", *response); response.send()?; } @@ -69,7 +69,7 @@ fn main() -> Result<(), Box> { counter += 1; } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/request_response_dynamic_data/client.rs b/examples/rust/request_response_dynamic_data/client.rs index a64fd4db2..8269895fd 100644 --- a/examples/rust/request_response_dynamic_data/client.rs +++ b/examples/rust/request_response_dynamic_data/client.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -49,7 +49,7 @@ fn main() -> Result<(), Box> { let request = request.write_from_fn(|byte_idx| ((byte_idx + counter) % 255) as u8); let pending_response = request.send()?; - println!("send request {counter} with {required_memory_size} bytes ..."); + cout!("send request {counter} with {required_memory_size} bytes ..."); if node.wait(CYCLE_TIME).is_err() { break; @@ -57,7 +57,7 @@ fn main() -> Result<(), Box> { // acquire all responses to our request from our buffer that were sent by the servers while let Some(response) = pending_response.receive()? { - println!( + cout!( " received response with {} bytes", response.payload().len() ); @@ -66,7 +66,7 @@ fn main() -> Result<(), Box> { counter += 1; } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/request_response_dynamic_data/server.rs b/examples/rust/request_response_dynamic_data/server.rs index 1f2baae12..34f6f24f4 100644 --- a/examples/rust/request_response_dynamic_data/server.rs +++ b/examples/rust/request_response_dynamic_data/server.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_millis(100); @@ -41,12 +41,12 @@ fn main() -> Result<(), Box> { .allocation_strategy(AllocationStrategy::PowerOfTwo) .create()?; - println!("Server ready to receive requests!"); + cout!("Server ready to receive requests!"); let mut counter = 1; while node.wait(CYCLE_TIME).is_ok() { while let Some(active_request) = server.receive()? { - println!( + cout!( "received request with {} bytes ...", active_request.payload().len() ); @@ -54,14 +54,14 @@ fn main() -> Result<(), Box> { let required_memory_size = 1_000_000.min(counter * counter); let response = active_request.loan_slice_uninit(required_memory_size)?; let response = response.write_from_fn(|byte_idx| ((byte_idx + counter) % 255) as u8); - println!(" send response with {} bytes", response.payload().len()); + cout!(" send response with {} bytes", response.payload().len()); response.send()?; } counter += 1; } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/service_attributes/creator.rs b/examples/rust/service_attributes/creator.rs index c19b3063f..9b2086a9e 100644 --- a/examples/rust/service_attributes/creator.rs +++ b/examples/rust/service_attributes/creator.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -42,7 +42,7 @@ fn main() -> Result<(), Box> { let publisher = service.publisher_builder().create()?; - println!("defined service attributes: {:?}", service.attributes()); + cout!("defined service attributes: {:?}", service.attributes()); while node.wait(CYCLE_TIME).is_ok() { let sample = publisher.loan_uninit()?; @@ -50,7 +50,7 @@ fn main() -> Result<(), Box> { sample.send()?; } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/service_attributes/incompatible.rs b/examples/rust/service_attributes/incompatible.rs index e8a52e735..2b4b11138 100644 --- a/examples/rust/service_attributes/incompatible.rs +++ b/examples/rust/service_attributes/incompatible.rs @@ -14,7 +14,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; fn main() -> Result<(), Box> { set_log_level_from_env_or(LogLevel::Info); @@ -29,7 +29,7 @@ fn main() -> Result<(), Box> { &AttributeVerifier::new() .require(&"camera_resolution".try_into()?, &"3840x2160".try_into()?)?, ) - .map_err(|e| println!("camera_resolution: 3840x2160 -> {:?}", e)); + .map_err(|e| cout!("camera_resolution: 3840x2160 -> {:?}", e)); let _incompatible_service = node .service_builder(&"Service/With/Properties".try_into()?) @@ -38,7 +38,7 @@ fn main() -> Result<(), Box> { // the opening of the service will fail since the key is not defined. &AttributeVerifier::new().require_key(&"camera_type".try_into()?)?, ) - .map_err(|e| println!("camera_type -> {:?}", e)); + .map_err(|e| cout!("camera_type -> {:?}", e)); Ok(()) } diff --git a/examples/rust/service_attributes/opener.rs b/examples/rust/service_attributes/opener.rs index 52774fdf4..2b27b3939 100644 --- a/examples/rust/service_attributes/opener.rs +++ b/examples/rust/service_attributes/opener.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_secs(1); @@ -37,15 +37,15 @@ fn main() -> Result<(), Box> { let subscriber = service.subscriber_builder().create()?; - println!("defined service attributes: {:?}", service.attributes()); + cout!("defined service attributes: {:?}", service.attributes()); while node.wait(CYCLE_TIME).is_ok() { while let Some(sample) = subscriber.receive()? { - println!("received: {:?}", *sample); + cout!("received: {:?}", *sample); } } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/service_types/ipc_publisher.rs b/examples/rust/service_types/ipc_publisher.rs index 7fcb29f18..6d7f9619f 100644 --- a/examples/rust/service_types/ipc_publisher.rs +++ b/examples/rust/service_types/ipc_publisher.rs @@ -16,7 +16,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; const CYCLE_TIME: Duration = Duration::from_millis(750); @@ -41,12 +41,12 @@ fn main() -> Result<(), Box> { let mut counter = 0u64; while node.wait(CYCLE_TIME).is_ok() { - println!("send: {counter}"); + cout!("send: {counter}"); publisher.send_copy(counter)?; counter += 1; } - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/service_types/ipc_threadsafe_subscriber.rs b/examples/rust/service_types/ipc_threadsafe_subscriber.rs index b0ca1f635..326b83216 100644 --- a/examples/rust/service_types/ipc_threadsafe_subscriber.rs +++ b/examples/rust/service_types/ipc_threadsafe_subscriber.rs @@ -18,7 +18,7 @@ use alloc::boxed::Box; use alloc::sync::Arc; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; use iceoryx2_bb_posix::clock::nanosleep; use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; @@ -52,21 +52,21 @@ fn main() -> Result<(), Box> { while KEEP_RUNNING.load(Ordering::Relaxed) { nanosleep(CYCLE_TIME).unwrap(); if let Some(sample) = in_thread_subscriber.receive().unwrap() { - println!("[thread] received: {}", sample.payload()); + cout!("[thread] received: {}", sample.payload()); } } })?; while node.wait(CYCLE_TIME).is_ok() { if let Some(sample) = subscriber.receive()? { - println!("[main] received: {}", sample.payload()); + cout!("[main] received: {}", sample.payload()); } } KEEP_RUNNING.store(false, Ordering::Relaxed); drop(other_thread); - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/examples/rust/service_types/local_pubsub.rs b/examples/rust/service_types/local_pubsub.rs index 71367ae58..c8cfcbf51 100644 --- a/examples/rust/service_types/local_pubsub.rs +++ b/examples/rust/service_types/local_pubsub.rs @@ -17,7 +17,7 @@ extern crate alloc; use alloc::boxed::Box; use iceoryx2::prelude::*; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; use iceoryx2_bb_posix::clock::nanosleep; use iceoryx2_bb_posix::thread::{ThreadBuilder, ThreadName}; @@ -44,7 +44,7 @@ fn background_thread() { while KEEP_RUNNING.load(Ordering::Relaxed) { nanosleep(CYCLE_TIME).unwrap(); while let Some(sample) = subscriber.receive().unwrap() { - println!("[thread] received: {}", sample.payload()); + cout!("[thread] received: {}", sample.payload()); } } } @@ -73,14 +73,14 @@ fn main() -> Result<(), Box> { let mut counter = 0u64; while node.wait(CYCLE_TIME).is_ok() { - println!("send: {counter}"); + cout!("send: {counter}"); publisher.send_copy(counter)?; counter += 1; } KEEP_RUNNING.store(false, Ordering::Relaxed); drop(background_thread); - println!("exit"); + cout!("exit"); Ok(()) } diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index 41dc23eb2..43d8477ce 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -320,14 +320,14 @@ pub fn __internal_print_log_msg(log_level: LogLevel, origin: Arguments, args: Ar // TODO(#1127): Add proper printing abstraction that can be implemented for no_std platforms #[cfg(feature = "std")] #[macro_export] -macro_rules! println { +macro_rules! cout { ($($arg:tt)*) => { std::println!($($arg)*) }; } #[cfg(feature = "std")] #[macro_export] -macro_rules! eprintln { +macro_rules! cerr { ($($arg:tt)*) => { std::eprintln!($($arg)*) }; @@ -335,11 +335,11 @@ macro_rules! eprintln { #[cfg(not(feature = "std"))] #[macro_export] -macro_rules! println { +macro_rules! cout { ($($arg:tt)*) => {{}}; } #[cfg(not(feature = "std"))] #[macro_export] -macro_rules! eprintln { +macro_rules! cerr { ($($arg:tt)*) => {{}}; } diff --git a/iceoryx2-bb/posix/src/config.rs b/iceoryx2-bb/posix/src/config.rs index 7e9843a02..b361dc56f 100644 --- a/iceoryx2-bb/posix/src/config.rs +++ b/iceoryx2-bb/posix/src/config.rs @@ -17,7 +17,7 @@ use core::time::Duration; use alloc::{format, string::ToString}; -use iceoryx2_bb_log::println; +use iceoryx2_bb_log::cout; use iceoryx2_bb_system_types::{file_name::FileName, path::Path, user_name::UserName}; use crate::{scheduler::Scheduler, system_configuration::*}; @@ -112,9 +112,9 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool let mut is_compliant: bool = true; if mode == ComplianceCheckMode::Verbose { - println!("{HEADER_COLOR}system requirements check{COLOR_RESET}"); - println!(""); - println!(" {HEADER_COLOR}minimum system{COLOR_RESET}"); + cout!("{HEADER_COLOR}system requirements check{COLOR_RESET}"); + cout!(""); + cout!(" {HEADER_COLOR}minimum system{COLOR_RESET}"); } for i in MIN_REQUIRED_SYSTEM.iter() { let supported_value = i.0.value(); @@ -128,7 +128,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + cout!( " {}{:<40}{} minimum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -144,8 +144,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(""); - println!(" {HEADER_COLOR}maximum system{COLOR_RESET}"); + cout!(""); + cout!(" {HEADER_COLOR}maximum system{COLOR_RESET}"); } for i in MAX_REQUIRED_SYSTEM.iter() { let supported_value = i.0.value(); @@ -159,7 +159,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + cout!( " {}{:<40}{} maximum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -175,8 +175,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(""); - println!(" {HEADER_COLOR}minimum limits{COLOR_RESET}"); + cout!(""); + cout!(" {HEADER_COLOR}minimum limits{COLOR_RESET}"); } for i in MIN_REQUIRED_LIMITS.iter() { let supported_value = i.0.value(); @@ -197,7 +197,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + cout!( " {}{:<40}{} minimum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -213,8 +213,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(""); - println!(" {HEADER_COLOR}maximum limits{COLOR_RESET}"); + cout!(""); + cout!(" {HEADER_COLOR}maximum limits{COLOR_RESET}"); } for i in MAX_REQUIRED_LIMITS.iter() { let supported_value = i.0.value(); @@ -235,7 +235,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + cout!( " {}{:<40}{} maximum: {}{:<15}{} current: {}{:<15}{}", entry_color, format!("{:?}", i.0), @@ -251,8 +251,8 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(""); - println!(" {HEADER_COLOR}features{COLOR_RESET}"); + cout!(""); + cout!(" {HEADER_COLOR}features{COLOR_RESET}"); } for i in REQUIRED_FEATURES.iter() { let is_supported = i.is_available(); @@ -265,7 +265,7 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool }; if mode == ComplianceCheckMode::Verbose { - println!( + cout!( " {}{:<40}{} required: {}{:<15}{} supported: {}{:<15}{}", entry_color, format!("{:?}", i), @@ -281,10 +281,10 @@ pub fn does_system_satisfy_posix_requirements(mode: ComplianceCheckMode) -> bool } if mode == ComplianceCheckMode::Verbose { - println!(""); + cout!(""); match !is_compliant { - true => println!(" {FAILED_COLOR}[ system non-compliant ]{COLOR_RESET}"), - false => println!(" [ system compliant ]"), + true => cout!(" {FAILED_COLOR}[ system non-compliant ]{COLOR_RESET}"), + false => cout!(" [ system compliant ]"), } } From 508b86d80b18e1f6f6e9239e6dbf88a87f20ddb4 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Sat, 25 Oct 2025 19:06:53 +0900 Subject: [PATCH 29/30] [#865] Decide Once implementation in iceoryx2-pal-concurrency-sync --- iceoryx2-bb/log/src/lib.rs | 4 ---- iceoryx2-ffi/c/src/api/log.rs | 3 --- iceoryx2-pal/concurrency-sync/Cargo.toml | 4 ++++ iceoryx2-pal/concurrency-sync/src/lib.rs | 11 +++++++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/iceoryx2-bb/log/src/lib.rs b/iceoryx2-bb/log/src/lib.rs index 43d8477ce..ccdd8232d 100644 --- a/iceoryx2-bb/log/src/lib.rs +++ b/iceoryx2-bb/log/src/lib.rs @@ -169,11 +169,7 @@ pub mod logger; pub use from_env::{set_log_level_from_env_or, set_log_level_from_env_or_default}; use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU8; - -#[cfg(not(feature = "std"))] use iceoryx2_pal_concurrency_sync::once::Once; -#[cfg(feature = "std")] -use std::sync::Once; use core::{fmt::Arguments, sync::atomic::Ordering}; diff --git a/iceoryx2-ffi/c/src/api/log.rs b/iceoryx2-ffi/c/src/api/log.rs index 1190ae229..c2dc0c573 100644 --- a/iceoryx2-ffi/c/src/api/log.rs +++ b/iceoryx2-ffi/c/src/api/log.rs @@ -23,10 +23,7 @@ use iceoryx2_bb_log::{ get_log_level, set_log_level, set_logger, Log, LogLevel, __internal_print_log_msg, }; -#[cfg(not(feature = "std"))] use iceoryx2_pal_concurrency_sync::once::Once; -#[cfg(feature = "std")] -use std::sync::Once; #[repr(C)] #[derive(Copy, Clone)] diff --git a/iceoryx2-pal/concurrency-sync/Cargo.toml b/iceoryx2-pal/concurrency-sync/Cargo.toml index 92f468c53..239a37653 100644 --- a/iceoryx2-pal/concurrency-sync/Cargo.toml +++ b/iceoryx2-pal/concurrency-sync/Cargo.toml @@ -10,6 +10,10 @@ repository = { workspace = true } rust-version = { workspace = true } version = { workspace = true } +[features] +default = [] +std = [] + [dependencies] [dev-dependencies] diff --git a/iceoryx2-pal/concurrency-sync/src/lib.rs b/iceoryx2-pal/concurrency-sync/src/lib.rs index 768b6495c..6f024fb1b 100644 --- a/iceoryx2-pal/concurrency-sync/src/lib.rs +++ b/iceoryx2-pal/concurrency-sync/src/lib.rs @@ -10,7 +10,7 @@ // // SPDX-License-Identifier: Apache-2.0 OR MIT -#![no_std] +#![cfg_attr(not(feature = "std"), no_std)] const SPIN_REPETITIONS: u64 = 10000; @@ -18,10 +18,17 @@ pub mod barrier; pub mod condition_variable; pub mod iox_atomic; pub mod mutex; -pub mod once; pub mod rwlock; pub mod semaphore; +#[cfg(not(feature = "std"))] +pub mod once; + +#[cfg(feature = "std")] +pub mod once { + pub use std::sync::Once; +} + #[derive(Debug, PartialEq, Eq)] pub enum WaitAction { Continue, From 3f45b32b3deab9d2b23510e6d6db7901f70263bf Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Sat, 25 Oct 2025 22:43:35 +0900 Subject: [PATCH 30/30] [#865] Use fatal_panic! on Mutex failures --- iceoryx2/src/node/mod.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index ed8051b05..8a92e4edd 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -751,19 +751,27 @@ unsafe impl Sync for RegisteredServices {} impl RegisteredServices { pub(crate) fn new() -> Self { + let origin = "RegisteredServices::new()"; let handle = MutexHandle::new(); - MutexBuilder::new() - .is_interprocess_capable(false) - .mutex_type(MutexType::Normal) - .create(BTreeMap::new(), &handle) - .expect("Failed to create mutex"); + fatal_panic!( + from origin, + when MutexBuilder::new() + .is_interprocess_capable(false) + .mutex_type(MutexType::Normal) + .create(BTreeMap::new(), &handle), + "Failed to create mutex" + ); Self { handle } } pub(crate) fn add(&self, service_id: &ServiceId, handle: ContainerHandle) { - let mut guard = self.mutex().lock().expect("Failed to lock mutex"); + let mut guard = fatal_panic!( + from self, + when self.mutex().lock(), + "Failed to lock mutex" + ); if guard.insert(*service_id, (handle, 1)).is_some() { fatal_panic!(from "RegisteredServices::add()", @@ -776,7 +784,11 @@ impl RegisteredServices { service_id: &ServiceId, mut or_callback: F, ) -> Result<(), OpenDynamicStorageFailure> { - let mut guard = self.mutex().lock().expect("Failed to lock mutex"); + let mut guard = fatal_panic!( + from self, + when self.mutex().lock(), + "Failed to lock mutex" + ); match guard.get_mut(service_id) { Some(entry) => {