diff --git a/rustecal-core/src/components.rs b/rustecal-core/src/components.rs index c68e249..d03bc91 100644 --- a/rustecal-core/src/components.rs +++ b/rustecal-core/src/components.rs @@ -5,7 +5,7 @@ //! //! The flags can be combined using bitwise OR operations (e.g., `PUBLISHER | LOGGING`). //! -//! These flags are passed to [`crate::ecal::core::Ecal::initialize`] to enable +//! These flags are passed to [`crate::Ecal::initialize`] to enable //! or disable subsystems for performance, resource usage, or system design reasons. use bitflags::bitflags; diff --git a/rustecal-core/src/log.rs b/rustecal-core/src/log.rs index 5f15536..f2b6380 100644 --- a/rustecal-core/src/log.rs +++ b/rustecal-core/src/log.rs @@ -51,7 +51,7 @@ impl Log { let logs = unsafe { let logging = &*raw_ptr; let raw_messages = logging.log_messages; - let len = logging.log_messages_length as usize; + let len = logging.log_messages_length; let entries = slice::from_raw_parts(raw_messages, len) .iter() diff --git a/rustecal-core/src/monitoring.rs b/rustecal-core/src/monitoring.rs index acd6c42..32a5e3d 100644 --- a/rustecal-core/src/monitoring.rs +++ b/rustecal-core/src/monitoring.rs @@ -49,7 +49,7 @@ impl Monitoring { // 5) Build the snapshot and free the C‑allocated memory let snapshot = unsafe { let processes = { - let cnt = (*raw).processes_length as usize; + let cnt = (*raw).processes_length; let ptr = (*raw).processes; slice::from_raw_parts(ptr, cnt) .iter() @@ -58,7 +58,7 @@ impl Monitoring { }; let publishers = { - let cnt = (*raw).publishers_length as usize; + let cnt = (*raw).publishers_length; let ptr = (*raw).publishers; slice::from_raw_parts(ptr, cnt) .iter() @@ -67,7 +67,7 @@ impl Monitoring { }; let subscribers = { - let cnt = (*raw).subscribers_length as usize; + let cnt = (*raw).subscribers_length; let ptr = (*raw).subscribers; slice::from_raw_parts(ptr, cnt) .iter() @@ -76,7 +76,7 @@ impl Monitoring { }; let servers = { - let cnt = (*raw).servers_length as usize; + let cnt = (*raw).servers_length; let ptr = (*raw).servers; slice::from_raw_parts(ptr, cnt) .iter() @@ -85,7 +85,7 @@ impl Monitoring { }; let clients = { - let cnt = (*raw).clients_length as usize; + let cnt = (*raw).clients_length; let ptr = (*raw).clients; slice::from_raw_parts(ptr, cnt) .iter() diff --git a/rustecal-service/src/types.rs b/rustecal-service/src/types.rs index a2adb4a..9cfa850 100644 --- a/rustecal-service/src/types.rs +++ b/rustecal-service/src/types.rs @@ -45,6 +45,12 @@ pub struct ServiceId { } impl ServiceId { + /// Constructs a `ServiceId` from its FFI representation. + /// + /// # Safety + /// - `raw` must refer to a valid, properly initialized `eCAL_SServiceId`. + /// - Any pointers inside `raw` must be non-null and correctly aligned. + /// - The memory behind `raw` must remain valid for the duration of this call. pub unsafe fn from_ffi(raw: &eCAL_SServiceId) -> Self { Self { service_id: raw.service_id, diff --git a/rustecal/src/lib.rs b/rustecal/src/lib.rs index 5edf1b5..04885f9 100644 --- a/rustecal/src/lib.rs +++ b/rustecal/src/lib.rs @@ -13,11 +13,9 @@ //! use rustecal::{Ecal, TypedPublisher}; //! use rustecal_types_string::StringMessage; //! -//! fn main() { -//! Ecal::initialize(Some("example node"), EcalComponents::DEFAULT, None).unwrap(); -//! let pub_ = TypedPublisher::::new("hello topic").unwrap(); -//! pub_.send(&StringMessage{data: "Hello!".into()}, Timestamp::Auto); -//! } +//! Ecal::initialize(Some("example node"), EcalComponents::DEFAULT, None).unwrap(); +//! let pub_ = TypedPublisher::::new("hello topic").unwrap(); +//! pub_.send(&StringMessage{data: "Hello!".into()}, Timestamp::Auto); //! ``` //!