Skip to content

Commit ba8e6ac

Browse files
Add Publisher::get_subscription_count
1 parent 83ab23a commit ba8e6ac

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

rclrs/src/publisher.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ where
146146
}
147147
}
148148

149+
/// Returns the number of subscriptions of the publisher.
150+
pub fn get_subscription_count(&self) -> usize {
151+
let mut subscription_count = 0;
152+
// SAFETY: No preconditions for the function called.
153+
let ret = unsafe {
154+
rcl_publisher_get_subscription_count(
155+
&*self.handle.rcl_publisher.lock().unwrap(),
156+
&mut subscription_count,
157+
)
158+
};
159+
debug_assert_eq!(ret, 0);
160+
subscription_count
161+
}
162+
149163
/// Publishes a message.
150164
///
151165
/// The [`MessageCow`] trait is implemented by any

0 commit comments

Comments
 (0)