#[non_exhaustive]pub enum GoalStatus {
Unknown,
Accepted,
Executing,
Canceling,
Succeeded,
Canceled,
Aborted,
}Expand description
The lifecycle state of an action goal (blueprint §9.4).
The discriminants match ROS 2’s action_msgs/msg/GoalStatus constants
exactly, so astrs-ros2 can bridge an action in either direction without
a translation table. The AstRS FSM proper is
Accepted → Executing → {Succeeded, Aborted, Canceled}; Canceling and
Unknown exist for ROS 2 fidelity.
§Examples
use astrs_wire::GoalStatus;
assert_eq!(GoalStatus::Executing.as_i64(), 2);
assert_eq!(GoalStatus::from_i64(4), Some(GoalStatus::Succeeded));
assert!(GoalStatus::Succeeded.is_terminal());
assert!(GoalStatus::Accepted.can_transition_to(GoalStatus::Executing));
assert!(!GoalStatus::Succeeded.can_transition_to(GoalStatus::Executing));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unknown
The goal’s state is not known (ROS 2 STATUS_UNKNOWN).
Accepted
The server accepted the goal but has not started it
(ROS 2 STATUS_ACCEPTED).
Executing
The server is executing the goal (ROS 2 STATUS_EXECUTING).
Canceling
A cancellation was requested and is being processed
(ROS 2 STATUS_CANCELING).
Succeeded
The goal completed successfully (ROS 2 STATUS_SUCCEEDED).
Canceled
The goal was cancelled (ROS 2 STATUS_CANCELED).
Aborted
The goal failed (ROS 2 STATUS_ABORTED).
Implementations§
Source§impl GoalStatus
impl GoalStatus
Sourcepub const ALL: &'static [GoalStatus]
pub const ALL: &'static [GoalStatus]
Every status, in discriminant order.
Sourcepub const fn as_i64(self) -> i64
pub const fn as_i64(self) -> i64
The numeric form stored under GOAL_STATUS.
Sourcepub const fn from_i64(code: i64) -> Option<GoalStatus>
pub const fn from_i64(code: i64) -> Option<GoalStatus>
Parses the numeric form.
Returns None for a code this build does not know, rather than
collapsing it to GoalStatus::Unknown — a caller that wants that
fallback should say so.
§Examples
use astrs_wire::GoalStatus;
assert_eq!(GoalStatus::from_i64(6), Some(GoalStatus::Aborted));
assert_eq!(GoalStatus::from_i64(7), None);
assert_eq!(GoalStatus::from_i64(-1), None);Sourcepub const fn is_terminal(self) -> bool
pub const fn is_terminal(self) -> bool
Whether the goal has reached a final state.
§Examples
use astrs_wire::GoalStatus;
assert!(GoalStatus::Canceled.is_terminal());
assert!(!GoalStatus::Canceling.is_terminal());Sourcepub const fn can_transition_to(self, next: GoalStatus) -> bool
pub const fn can_transition_to(self, next: GoalStatus) -> bool
Whether next is a legal successor of self in the goal FSM.
Servers use this to reject a status update that would move a goal backwards or out of a terminal state, which is the failure mode that leaves a client waiting forever.
§Examples
use astrs_wire::GoalStatus;
assert!(GoalStatus::Unknown.can_transition_to(GoalStatus::Accepted));
assert!(GoalStatus::Executing.can_transition_to(GoalStatus::Canceling));
assert!(GoalStatus::Canceling.can_transition_to(GoalStatus::Canceled));
assert!(!GoalStatus::Accepted.can_transition_to(GoalStatus::Unknown));
assert!(!GoalStatus::Aborted.can_transition_to(GoalStatus::Aborted));Trait Implementations§
Source§impl Clone for GoalStatus
impl Clone for GoalStatus
Source§fn clone(&self) -> GoalStatus
fn clone(&self) -> GoalStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more