File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,20 @@ pub trait Message: Clone + Debug + Default + 'static + Send + Sync {
144
144
fn from_rmw_message ( msg : Self :: RmwMsg ) -> Self ;
145
145
}
146
146
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
+
147
161
/// Trait for services.
148
162
///
149
163
/// User code never needs to call this trait's method, much less implement this trait.
You can’t perform that action at this time.
0 commit comments