pub struct CallbackCtx<'a> { /* private fields */ }Expand description
Context handed to an executable component callback body (W.5.1).
Carries the triggering payload (raw CDR — empty for timers) plus the
publisher resolver, so a body can read its message and publish immediately.
Service / action-result callbacks additionally carry a ReplySink the body
fills via reply; action goal / cancel callbacks carry a
DecisionSink the body fills via
set_goal_response /
set_cancel_response (W.5.3).
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.
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.