File tree Expand file tree Collapse file tree 4 files changed +57
-31
lines changed Expand file tree Collapse file tree 4 files changed +57
-31
lines changed Original file line number Diff line number Diff line change @@ -294,18 +294,25 @@ pub struct ClientOptions<'a> {
294
294
pub qos : QoSProfile ,
295
295
}
296
296
297
- impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for ClientOptions < ' a > {
298
- fn from ( value : T ) -> Self {
299
- let options = value. into_primitive_options ( ) ;
300
- let mut qos = QoSProfile :: services_default ( ) ;
301
- options. apply ( & mut qos) ;
297
+ impl < ' a > ClientOptions < ' a > {
298
+ /// Initialize a new [`ClientOptions`] with default settings.
299
+ pub fn new ( service_name : & ' a str ) -> Self {
302
300
Self {
303
- service_name : options . name ,
304
- qos,
301
+ service_name,
302
+ qos : QoSProfile :: services_default ( ) ,
305
303
}
306
304
}
307
305
}
308
306
307
+ impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for ClientOptions < ' a > {
308
+ fn from ( value : T ) -> Self {
309
+ let primitive = value. into_primitive_options ( ) ;
310
+ let mut options = Self :: new ( primitive. name ) ;
311
+ primitive. apply ( & mut options. qos ) ;
312
+ options
313
+ }
314
+ }
315
+
309
316
impl < T > ClientBase for Client < T >
310
317
where
311
318
T : rosidl_runtime_rs:: Service ,
Original file line number Diff line number Diff line change @@ -244,18 +244,25 @@ pub struct PublisherOptions<'a> {
244
244
pub qos : QoSProfile ,
245
245
}
246
246
247
- impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for PublisherOptions < ' a > {
248
- fn from ( value : T ) -> Self {
249
- let options = value. into_primitive_options ( ) ;
250
- let mut qos = QoSProfile :: topics_default ( ) ;
251
- options. apply ( & mut qos) ;
247
+ impl < ' a > PublisherOptions < ' a > {
248
+ /// Initialize a new [`PublisherOptions`] with default settings.
249
+ pub fn new ( topic : & ' a str ) -> Self {
252
250
Self {
253
- topic : options . name ,
254
- qos,
251
+ topic,
252
+ qos : QoSProfile :: topics_default ( ) ,
255
253
}
256
254
}
257
255
}
258
256
257
+ impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for PublisherOptions < ' a > {
258
+ fn from ( value : T ) -> Self {
259
+ let primitive = value. into_primitive_options ( ) ;
260
+ let mut options = Self :: new ( primitive. name ) ;
261
+ primitive. apply ( & mut options. qos ) ;
262
+ options
263
+ }
264
+ }
265
+
259
266
/// Convenience trait for [`Publisher::publish`].
260
267
pub trait MessageCow < ' a , T : Message > {
261
268
/// Wrap the owned or borrowed message in a `Cow`.
Original file line number Diff line number Diff line change @@ -190,22 +190,29 @@ where
190
190
pub struct ServiceOptions < ' a > {
191
191
/// The name for the service
192
192
pub name : & ' a str ,
193
- /// The quality of service for the service.
193
+ /// The quality of service profile for the service.
194
194
pub qos : QoSProfile ,
195
195
}
196
196
197
- impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for ServiceOptions < ' a > {
198
- fn from ( value : T ) -> Self {
199
- let options = value. into_primitive_options ( ) ;
200
- let mut qos = QoSProfile :: services_default ( ) ;
201
- options. apply ( & mut qos) ;
197
+ impl < ' a > ServiceOptions < ' a > {
198
+ /// Initialize a new [`ServiceOptions`] with default settings.
199
+ pub fn new ( name : & ' a str ) -> Self {
202
200
Self {
203
- name : options . name ,
204
- qos,
201
+ name,
202
+ qos : QoSProfile :: services_default ( ) ,
205
203
}
206
204
}
207
205
}
208
206
207
+ impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for ServiceOptions < ' a > {
208
+ fn from ( value : T ) -> Self {
209
+ let primitive = value. into_primitive_options ( ) ;
210
+ let mut options = Self :: new ( primitive. name ) ;
211
+ primitive. apply ( & mut options. qos ) ;
212
+ options
213
+ }
214
+ }
215
+
209
216
impl < T > ServiceBase for Service < T >
210
217
where
211
218
T : rosidl_runtime_rs:: Service ,
Original file line number Diff line number Diff line change @@ -274,20 +274,25 @@ pub struct SubscriptionOptions<'a> {
274
274
pub qos : QoSProfile ,
275
275
}
276
276
277
- impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for SubscriptionOptions < ' a > {
278
- fn from ( value : T ) -> Self {
279
- let options = value. into_primitive_options ( ) ;
280
- // Topics will use the QOS_PROFILE_DEFAULT by default, which is designed
281
- // to roughly match the ROS 1 default topic behavior.
282
- let mut qos = QoSProfile :: topics_default ( ) ;
283
- options. apply ( & mut qos) ;
277
+ impl < ' a > SubscriptionOptions < ' a > {
278
+ /// Initialize a new [`SubscriptionOptions`] with default settings.
279
+ pub fn new ( topic : & ' a str ) -> Self {
284
280
Self {
285
- topic : options . name ,
286
- qos,
281
+ topic,
282
+ qos : QoSProfile :: topics_default ( ) ,
287
283
}
288
284
}
289
285
}
290
286
287
+ impl < ' a , T : IntoPrimitiveOptions < ' a > > From < T > for SubscriptionOptions < ' a > {
288
+ fn from ( value : T ) -> Self {
289
+ let primitive = value. into_primitive_options ( ) ;
290
+ let mut options = Self :: new ( primitive. name ) ;
291
+ primitive. apply ( & mut options. qos ) ;
292
+ options
293
+ }
294
+ }
295
+
291
296
impl < T > SubscriptionBase for Subscription < T >
292
297
where
293
298
T : Message ,
You can’t perform that action at this time.
0 commit comments