use super::{FeedbackPublisher, LiveActionServerGoal, TerminatedGoal};
use rosidl_runtime_rs::Action;
use std::sync::Arc;
pub struct CancellingGoal<A: Action> {
live: Arc<LiveActionServerGoal<A>>,
}
impl<A: Action> CancellingGoal<A> {
#[must_use]
pub fn goal(&self) -> &Arc<A::Goal> {
self.live.goal()
}
pub fn cancelled_with(self, result: A::Result) -> TerminatedGoal {
self.live.transition_to_cancelled(result);
TerminatedGoal {
uuid: *self.live.goal_id(),
}
}
pub fn succeeded_with(self, result: A::Result) -> TerminatedGoal {
self.live.transition_to_succeed(result);
TerminatedGoal {
uuid: *self.live.goal_id(),
}
}
pub fn aborted_with(self, result: A::Result) -> TerminatedGoal {
self.live.transition_to_aborted(result);
TerminatedGoal {
uuid: *self.live.goal_id(),
}
}
pub fn publish_feedback(&self, feedback: A::Feedback) {
self.live.publish_feedback(feedback);
}
pub fn feedback_publisher(&self) -> FeedbackPublisher<A> {
FeedbackPublisher::new(Arc::clone(&self.live))
}
pub(super) fn new(live: Arc<LiveActionServerGoal<A>>) -> Self {
live.transition_to_cancelling();
Self { live }
}
}