17
17
18
18
use crate :: error:: { to_rclrs_result, RclReturnCode , RclrsError , ToResult } ;
19
19
use crate :: rcl_bindings:: * ;
20
- use crate :: { Client , Context , Service , Subscription } ;
20
+ use crate :: { ClientWaitable , Context , ServiceWaitable , SubscriptionWaitable } ;
21
21
22
22
use std:: sync:: Arc ;
23
23
use std:: time:: Duration ;
@@ -59,19 +59,19 @@ pub struct WaitSet {
59
59
// The subscriptions that are currently registered in the wait set.
60
60
// This correspondence is an invariant that must be maintained by all functions,
61
61
// even in the error case.
62
- pub ( crate ) subscriptions : Vec < Arc < dyn Waitable > > ,
63
- pub ( crate ) clients : Vec < Arc < dyn Waitable > > ,
64
- pub ( crate ) services : Vec < Arc < dyn Waitable > > ,
62
+ pub ( crate ) subscriptions : Vec < Arc < dyn SubscriptionWaitable > > ,
63
+ pub ( crate ) clients : Vec < Arc < dyn ClientWaitable > > ,
64
+ pub ( crate ) services : Vec < Arc < dyn ServiceWaitable > > ,
65
65
}
66
66
67
67
/// A list of entities that are ready, returned by [`WaitSet::wait`].
68
68
pub struct ReadyEntities {
69
69
/// A list of subscriptions that have potentially received messages.
70
- pub subscriptions : Vec < Arc < dyn Waitable > > ,
70
+ pub subscriptions : Vec < Arc < dyn SubscriptionWaitable > > ,
71
71
/// A list of clients that have potentially received responses.
72
- pub clients : Vec < Arc < dyn Waitable > > ,
72
+ pub clients : Vec < Arc < dyn ClientWaitable > > ,
73
73
/// A list of services that have potentially received requests.
74
- pub services : Vec < Arc < dyn Waitable > > ,
74
+ pub services : Vec < Arc < dyn ServiceWaitable > > ,
75
75
}
76
76
77
77
impl Drop for rcl_wait_set_t {
@@ -135,10 +135,7 @@ impl WaitSet {
135
135
///
136
136
/// The same client must not be added to multiple wait sets, because that would make it
137
137
/// unsafe to simultaneously wait on those wait sets.
138
- pub fn add_client < T : rosidl_runtime_rs:: Service > (
139
- & mut self ,
140
- client : Arc < Client < T > > ,
141
- ) -> Result < ( ) , RclrsError > {
138
+ pub fn add_client ( & mut self , client : Arc < dyn ClientWaitable > ) -> Result < ( ) , RclrsError > {
142
139
// SAFETY: The implementation of this trait for clients checks that the client
143
140
// has not already been added to a different wait set.
144
141
unsafe { client. add_to_wait_set ( self ) }
@@ -153,10 +150,7 @@ impl WaitSet {
153
150
///
154
151
/// The same service must not be added to multiple wait sets, because that would make it
155
152
/// unsafe to simultaneously wait on those wait sets.
156
- pub fn add_service < T : rosidl_runtime_rs:: Service > (
157
- & mut self ,
158
- service : Arc < Service < T > > ,
159
- ) -> Result < ( ) , RclrsError > {
153
+ pub fn add_service ( & mut self , service : Arc < dyn ServiceWaitable > ) -> Result < ( ) , RclrsError > {
160
154
// SAFETY: The implementation of this trait for services checks that the service
161
155
// has not already been added to a different wait set.
162
156
unsafe { service. add_to_wait_set ( self ) }
@@ -171,9 +165,9 @@ impl WaitSet {
171
165
///
172
166
/// The same subscription must not be added to multiple wait sets, because that would make it
173
167
/// unsafe to simultaneously wait on those wait sets.
174
- pub fn add_subscription < T : rosidl_runtime_rs :: Message > (
168
+ pub fn add_subscription (
175
169
& mut self ,
176
- subscription : Arc < Subscription < T > > ,
170
+ subscription : Arc < dyn SubscriptionWaitable > ,
177
171
) -> Result < ( ) , RclrsError > {
178
172
// SAFETY: The implementation of this trait for subscriptions checks that the subscription
179
173
// has not already been added to a different wait set.
0 commit comments