File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
rclrs/src/action/action_client Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,40 @@ impl<A: Action> GoalClient<A> {
8585 }
8686}
8787
88- /// Use this to
88+ /// Use this to receive a stream of messages from the action server which may be
89+ /// a mix of feedback messages, status updates, and the final result. These are
90+ /// multiplexed by the [`GoalEvent`] enum.
91+ ///
92+ /// Remember to `use futures::StreamExt;` in order to use the streaming trait
93+ /// of this struct.
94+ ///
95+ /// # Example
96+ ///
97+ /// ```
98+ /// use rclrs::*;
99+ /// use crate::rclrs::vendor::example_interfaces::action::Fibonacci;
100+ /// use futures::StreamExt;
101+ ///
102+ /// async fn process_goal_client_stream(
103+ /// mut goal_client_stream: GoalClientStream<Fibonacci>
104+ /// ) {
105+ /// while let Some(event) = goal_client_stream.next().await {
106+ /// match event {
107+ /// GoalEvent::Feedback(feedback) => {
108+ /// println!("Received feedback: {feedback:?}");
109+ /// }
110+ /// GoalEvent::Status(status) => {
111+ /// println!("Received status update: {status:?}");
112+ /// }
113+ /// GoalEvent::Result((status, result)) => {
114+ /// println!("Received the final status: {status:?}");
115+ /// println!("The result was: {result:?}");
116+ /// break;
117+ /// }
118+ /// }
119+ /// }
120+ /// }
121+ /// ```
89122pub struct GoalClientStream < A : Action > {
90123 stream_map : StreamMap < i32 , Pin < Box < dyn Stream < Item = GoalEvent < A > > + Send > > > ,
91124}
You can’t perform that action at this time.
0 commit comments