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 nros_cancel_response_t and C++’s nros::CancelResponse
carry. It used to be the action_msgs/srv/CancelGoal RPC return code
(now nros_core::CancelReturnCode), 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 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
DeclaredNode::create_publisher_for_topic, allowing simple callback
bodies to use the ROS topic literal instead of restating an unrelated
stable entity ID.