From 042c4567671c4882fe24dc93e3f77f87be288731 Mon Sep 17 00:00:00 2001 From: Milan Vukov Date: Sun, 24 Nov 2024 12:48:41 +0100 Subject: [PATCH 1/2] Add Publisher::can_loan_msgs --- rclrs/src/publisher.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rclrs/src/publisher.rs b/rclrs/src/publisher.rs index 2935ca322..5f3b830cb 100644 --- a/rclrs/src/publisher.rs +++ b/rclrs/src/publisher.rs @@ -229,6 +229,13 @@ where msg_ptr: msg_ptr as *mut T, }) } + + /// Returns true if message loans are possible, false otherwise. + pub fn can_loan_messages(&self) -> bool { + unsafe { + rcl_publisher_can_loan_messages(&*self.handle.rcl_publisher.lock().unwrap()) + } + } } /// Convenience trait for [`Publisher::publish`]. From 6240a6b145e07fa73b294a3614529a36644b3eee Mon Sep 17 00:00:00 2001 From: Milan Vukov Date: Sun, 24 Nov 2024 12:56:31 +0100 Subject: [PATCH 2/2] Fix formatting --- rclrs/src/publisher.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rclrs/src/publisher.rs b/rclrs/src/publisher.rs index 5f3b830cb..b1cdd93b9 100644 --- a/rclrs/src/publisher.rs +++ b/rclrs/src/publisher.rs @@ -232,9 +232,7 @@ where /// Returns true if message loans are possible, false otherwise. pub fn can_loan_messages(&self) -> bool { - unsafe { - rcl_publisher_can_loan_messages(&*self.handle.rcl_publisher.lock().unwrap()) - } + unsafe { rcl_publisher_can_loan_messages(&*self.handle.rcl_publisher.lock().unwrap()) } } }