pub struct CallbackCtx<'a> { /* private fields */ }Implementations§
Source§impl<'a> CallbackCtx<'a>
impl<'a> CallbackCtx<'a>
Sourcepub fn new(payload: &'a [u8], publishers: &'a dyn PublisherResolver) -> Self
pub fn new(payload: &'a [u8], publishers: &'a dyn PublisherResolver) -> Self
Build a callback context with no reply sink (timer / subscription).
payload is the entity’s raw CDR (empty slice for timers).
Sourcepub fn with_reply(
payload: &'a [u8],
publishers: &'a dyn PublisherResolver,
reply_buf: &'a mut [u8],
reply_written: &'a mut usize,
) -> Self
pub fn with_reply( payload: &'a [u8], publishers: &'a dyn PublisherResolver, reply_buf: &'a mut [u8], reply_written: &'a mut usize, ) -> Self
Build a callback context with a reply sink (service / action-result;
W.5.3). The body fills reply_buf via reply; the
generated trampoline reads *reply_written back as the response length.
Sourcepub fn with_goal_decision(
payload: &'a [u8],
publishers: &'a dyn PublisherResolver,
out: &'a mut GoalResponse,
) -> Self
pub fn with_goal_decision( payload: &'a [u8], publishers: &'a dyn PublisherResolver, out: &'a mut GoalResponse, ) -> Self
Build a context for an action goal callback (W.5.3): the body decides
accept/reject via set_goal_response; the
generated trampoline returns *out. payload is the goal CDR.
Sourcepub fn with_cancel_decision(
payload: &'a [u8],
publishers: &'a dyn PublisherResolver,
out: &'a mut CancelResponse,
) -> Self
pub fn with_cancel_decision( payload: &'a [u8], publishers: &'a dyn PublisherResolver, out: &'a mut CancelResponse, ) -> Self
Build a context for an action cancel callback (W.5.3): the body decides
accept/reject via set_cancel_response.
Sourcepub fn set_goal_response(&mut self, response: GoalResponse) -> NodeResult<()>
pub fn set_goal_response(&mut self, response: GoalResponse) -> NodeResult<()>
Set the action goal-callback’s accept/reject decision (W.5.3). Err when
the callback is not a goal decision.
Sourcepub fn set_cancel_response(
&mut self,
response: CancelResponse,
) -> NodeResult<()>
pub fn set_cancel_response( &mut self, response: CancelResponse, ) -> NodeResult<()>
Set the action cancel-callback’s accept/reject decision (W.5.3). Err when
the callback is not a cancel decision.
Issue 0796 — CancelResponse here is the PER-GOAL decision
(Reject / Accept), the twin of GoalResponse and the same two
values C’s rclc_cancel_response_t and C++’s nros::CancelResponse
carry. It used to be the action_msgs/srv/CancelGoal RPC return code
(now nros_core::CancelResponseCode), so answering “cancel this goal”
was spelled CancelResponse::Ok — a whole-request status code used to
decide one goal.
Sourcepub fn reply_raw(&mut self, data: &[u8]) -> NodeResult<()>
pub fn reply_raw(&mut self, data: &[u8]) -> NodeResult<()>
Write the service / action reply as raw CDR bytes (W.5.3). Err when the
callback has no reply sink (timer / subscription) or the reply exceeds the
lent buffer.
Sourcepub fn reply<M: RosMessage, const N: usize>(
&mut self,
msg: &M,
) -> NodeResult<()>
pub fn reply<M: RosMessage, const N: usize>( &mut self, msg: &M, ) -> NodeResult<()>
Serialize msg and write it as the service / action reply (W.5.3).
Sourcepub fn payload(&self) -> &[u8] ⓘ
pub fn payload(&self) -> &[u8] ⓘ
Raw CDR payload of the triggering message / request. Empty for timers.
Sourcepub fn timer_info(&self) -> Option<&TimerCallInfo>
pub fn timer_info(&self) -> Option<&TimerCallInfo>
Issue 2038 — the call info of the timer activation being dispatched:
when it was due (expected_call_time) and when the executor ran it
(actual_call_time), in nanoseconds on the timer’s clock. Some only
in a declared TIMER’s callback; None for subscriptions, services and
actions. The same two numbers Node::create_timer_with_info and C++’s
rclcpp::TimerInfo receive — one producer, the executor’s dispatcher.
Sourcepub fn reset_timer(&self, timer: EntityId<'_>) -> NodeResult<()>
pub fn reset_timer(&self, timer: EntityId<'_>) -> NodeResult<()>
Issue 2075 — reset the declared timer timer: rclcpp’s
TimerBase::reset(). Starts a timer declared with autostart = false
(DeclarativeNode::create_timer_for_callback_name_with_autostart),
and restarts a running one on a fresh period.
The request is applied at this component’s next tick, in the same
spin, once the callbacks of the pass have run: a callback does not hold
the executor. timer is the timer’s entity id, which for the
..._for_callback_name verbs is the callback name. Answers
NodeDeclError::UnknownTimer when this component has no controllable
timer by that id (see EntityBounds::timers).
ctx.reset_timer(nros::EntityId::new("on_tick"))?;Sourcepub fn cancel_timer(&self, timer: EntityId<'_>) -> NodeResult<()>
pub fn cancel_timer(&self, timer: EntityId<'_>) -> NodeResult<()>
Issue 2075 — cancel the declared timer timer: rclcpp’s
TimerBase::cancel(). It stops firing until reset_timer.
Applied at the next tick, like reset_timer.
Sourcepub fn message<M: RosMessage>(&self) -> NodeResult<M>
pub fn message<M: RosMessage>(&self) -> NodeResult<M>
Deserialize the triggering payload as M (subscription / service-request
bodies). Err if the payload is malformed for M.
Sourcepub fn publish_to_topic<M: RosMessage, const N: usize>(
&self,
topic: &str,
msg: &M,
) -> NodeResult<()>
pub fn publish_to_topic<M: RosMessage, const N: usize>( &self, topic: &str, msg: &M, ) -> NodeResult<()>
Serialize msg and publish through the entity synthesized from topic.
This pairs with
DeclarativeNode::create_publisher_for_topic, allowing simple callback
bodies to use the ROS topic literal instead of restating an unrelated
stable entity ID.