Skip to content

Commit e7d13b5

Browse files
committed
Generalize callbacks for subscriptions (#260)
* Generalize callbacks to subscriptions By implementing a trait (SubscriptionCallback) on valid function signatures, and making subscriptions accept callbacks that implement this trait, we can now * Receive both plain and boxed messages * Optionally receive a MessageInfo along with the message, as the second argument * Soon, receive a loaned message instead of an owned one This corresponds to the functionality in any_subscription_callback.hpp in rclcpp.
1 parent 0d72d26 commit e7d13b5

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

rosidl_runtime_rs/src/traits.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,6 @@ pub trait Message: Clone + Debug + Default + 'static + Send + Sync {
144144
fn from_rmw_message(msg: Self::RmwMsg) -> Self;
145145
}
146146

147-
/// Allows boxed values to be used by users in Publishers and Subscriptions.
148-
// See https://github.com/ros2-rust/ros2_rust/pull/235 for a discussion of possible alternatives.
149-
impl<T: Message> Message for Box<T> {
150-
type RmwMsg = T::RmwMsg;
151-
152-
fn into_rmw_message(msg_cow: Cow<'_, Self>) -> Cow<'_, Self::RmwMsg> {
153-
T::into_rmw_message(Cow::Owned(*msg_cow.into_owned()))
154-
}
155-
156-
fn from_rmw_message(msg: Self::RmwMsg) -> Self {
157-
Box::new(T::from_rmw_message(msg))
158-
}
159-
}
160-
161147
/// Trait for services.
162148
///
163149
/// User code never needs to call this trait's method, much less implement this trait.

0 commit comments

Comments
 (0)