Skip to content

Commit

Permalink
Add Publisher::get_subscription_count
Browse files Browse the repository at this point in the history
  • Loading branch information
romainreignier committed Feb 3, 2025
1 parent 83ab23a commit ba8e6ac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rclrs/src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ where
}
}

/// Returns the number of subscriptions of the publisher.
pub fn get_subscription_count(&self) -> usize {
let mut subscription_count = 0;
// SAFETY: No preconditions for the function called.
let ret = unsafe {
rcl_publisher_get_subscription_count(
&*self.handle.rcl_publisher.lock().unwrap(),
&mut subscription_count,
)
};
debug_assert_eq!(ret, 0);
subscription_count
}

/// Publishes a message.
///
/// The [`MessageCow`] trait is implemented by any
Expand Down

0 comments on commit ba8e6ac

Please sign in to comment.