#[repr(transparent)]pub struct ShutdownCallbackHandle(pub u32);Expand description
Handle to a registered shutdown hook, returned by
Executor::add_pre_shutdown_callback /
Executor::add_on_shutdown_callback and consumed by the matching
remove_*. rclcpp’s PreShutdownCallbackHandle / OnShutdownCallbackHandle.
§Why an index and not a pointer
rclcpp’s handle owns a std::shared_ptr to the callback. There is no
allocator here and the hooks live in a fixed-capacity static table, so the
handle is the SLOT INDEX — the smallest thing that identifies a row of a
static array, and trivially passable through the C ABI as one uint32_t.
The phase is packed into the high half rather than left implicit, so a handle from one list cannot silently remove a callback from the other. A slot index is only meaningful next to the table it indexes, and there are two tables.
Tuple Fields§
§0: u32Implementations§
Source§impl ShutdownCallbackHandle
impl ShutdownCallbackHandle
Sourcepub const INVALID: ShutdownCallbackHandle
pub const INVALID: ShutdownCallbackHandle
The value no registration ever returns. C callers compare against
NROS_SHUTDOWN_CALLBACK_HANDLE_INVALID, which is this number.
Sourcepub const fn new(
phase: ShutdownPhase,
index: usize,
) -> Option<ShutdownCallbackHandle>
pub const fn new( phase: ShutdownPhase, index: usize, ) -> Option<ShutdownCallbackHandle>
Pack a (phase, slot) pair. None when index does not fit the
16-bit index field — unreachable for any table this crate builds, and
an honest None rather than a silent truncation if one ever grows.
Sourcepub const fn phase(self) -> Option<ShutdownPhase>
pub const fn phase(self) -> Option<ShutdownPhase>
The phase this handle was issued for, or None if the value is not a
handle this crate ever issued (including Self::INVALID).
Trait Implementations§
Source§impl Clone for ShutdownCallbackHandle
impl Clone for ShutdownCallbackHandle
Source§fn clone(&self) -> ShutdownCallbackHandle
fn clone(&self) -> ShutdownCallbackHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ShutdownCallbackHandle
Source§impl Debug for ShutdownCallbackHandle
impl Debug for ShutdownCallbackHandle
impl Eq for ShutdownCallbackHandle
Source§impl PartialEq for ShutdownCallbackHandle
impl PartialEq for ShutdownCallbackHandle
Source§fn eq(&self, other: &ShutdownCallbackHandle) -> bool
fn eq(&self, other: &ShutdownCallbackHandle) -> bool
self and other values to be equal, and is used by ==.