Skip to main content

DeclarativeNode

Trait DeclarativeNode 

Source
pub trait DeclarativeNode {
Show 22 methods // Provided methods fn callback_group(&mut self, group: &str) -> NodeResult<&mut Self> where Self: Sized { ... } fn create_publisher_for_topic<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, ) -> NodeResult<NodePublisher<'entity, M>> { ... } fn create_publisher_for_topic_with_qos<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, qos: QoSProfile, ) -> NodeResult<NodePublisher<'entity, M>> { ... } fn create_subscription_for_callback_name<'callback, M: MessageForRmw>( &mut self, callback_name: &'callback str, topic: &str, ) -> NodeResult<NodeSubscription<'callback, M>> { ... } fn create_subscription_for_callback_name_with_safety<'callback, M: MessageForRmw>( &mut self, callback_name: &'callback str, topic: &str, ) -> NodeResult<NodeSubscription<'callback, M>> { ... } fn create_subscription_for_topic<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, ) -> NodeResult<NodeSubscription<'entity, M>> { ... } fn create_subscription_for_topic_with_qos<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, qos: QoSProfile, ) -> NodeResult<NodeSubscription<'entity, M>> { ... } fn create_subscription_static<M: MessageForRmw>( &mut self, topic: &'static str, ) -> NodeResult<SubscriptionTag> { ... } fn create_timer_for_callback_name<'callback>( &mut self, callback_name: &'callback str, period: TimerDuration, ) -> NodeResult<NodeTimer<'callback>> { ... } fn create_timer_for_callback_name_on_clock<'callback>( &mut self, callback_name: &'callback str, period: TimerDuration, clock: TimerClockSource, ) -> NodeResult<NodeTimer<'callback>> { ... } fn create_service_server_for_name<'entity, S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeServiceServer<'entity, S>> { ... } fn create_service_server_for_name_with_callback<'entity, S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'entity str, callback_name: &str, ) -> NodeResult<NodeServiceServer<'entity, S>> { ... } fn create_service_static<S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'static str, ) -> NodeResult<ServiceTag> { ... } fn create_service_client_for_name<'entity, S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeServiceClient<'entity, S>> { ... } fn create_action_server_for_name<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeActionServer<'entity, A>> { ... } fn create_action_server_for_name_with_callbacks<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, goal_callback_name: &str, cancel_callback_name: &str, accepted_callback_name: &str, ) -> NodeResult<NodeActionServer<'entity, A>> { ... } fn create_action_static<A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'static str, ) -> NodeResult<ActionTag> { ... } fn create_action_client_for_name<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeActionClient<'entity, A>> { ... } fn create_action_client_with_callbacks_for_name<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, result_callback_name: &str, feedback_callback_name: &str, ) -> NodeResult<NodeActionClient<'entity, A>> { ... } fn declare_parameter_for_name<'entity>( &mut self, name: &'entity str, parameter_type: ParameterType, ) -> NodeResult<NodeParameter<'entity>> { ... } fn declare_parameter_for_name_with_default<'entity>( &mut self, name: &'entity str, default: ParameterDefault, ) -> NodeResult<NodeParameter<'entity>> { ... } fn callback_for_name<'callback>( &mut self, name: &'callback str, ) -> CallbackEffects<'_, 'callback> { ... }
}
Expand description

phase-483 W3 — the DECLARATIVE entity constructors, on the one node type.

A component’s register creates its node with NodeContext::create_node and gets a crate::Node, the same type a standalone program gets from Executor::create_node. Everything rclrs’s node has is an inherent method there. The constructors here are the RTOS extension a component adds on top: each one DECLARES an entity — a stable id, a callback NAME, effects — to the component runtime, which owns the entity in the component’s static cell and dispatches its callback by name to ExecutableNode::on_callback. That is what framework dispatch (RTIC/Embassy) and the metadata probe need, and what a closure cannot give them.

Only callable inside a component’s register: outside one there is no component to declare into, and every method answers NodeDeclError::Runtime.

The explicit-id forms that would collide with an rclrs-named inherent method on Node are spelled declare_* (declare_publisher, declare_subscription, declare_timer, …).

Provided Methods§

Source

fn callback_group(&mut self, group: &str) -> NodeResult<&mut Self>
where Self: Sized,

Set the sticky callback-group label applied to every entity declared after this call (until changed again). The group is the symbolic name the node author exposes; system.toml maps it to a scheduling tier (RFC-0015). Entities declared while no group is set remain unlabeled (wildcard-eligible).

Source

fn create_publisher_for_topic<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, ) -> NodeResult<NodePublisher<'entity, M>>

Declare a publisher using topic as the stable entity ID.

Use the explicit declare_publisher form when a node declares more than one publisher on the same topic or needs a stable metadata ID that differs from the ROS topic name.

Source

fn create_publisher_for_topic_with_qos<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, qos: QoSProfile, ) -> NodeResult<NodePublisher<'entity, M>>

Declare a publisher with explicit QoS, using topic as the stable entity ID.

Source

fn create_subscription_for_callback_name<'callback, M: MessageForRmw>( &mut self, callback_name: &'callback str, topic: &str, ) -> NodeResult<NodeSubscription<'callback, M>>

Declare a subscription using callback_name as the source callback name and synthesized entity ID.

Source

fn create_subscription_for_callback_name_with_safety<'callback, M: MessageForRmw>( &mut self, callback_name: &'callback str, topic: &str, ) -> NodeResult<NodeSubscription<'callback, M>>

Phase 250 (Wave 2b) — declare a subscription with E2E message-integrity validation enabled (the declarative .safety() opt-in). Identical to create_subscription_for_callback_name but flags the entity so the runtime registers it via create_generic_subscription_with_integrity; the callback then reads CallbackCtx::integrity alongside the message. The config-driven [safety] axis (Wave 4 codegen) emits this call; it is also usable by hand. Ungated — when safety-e2e is off the flag is simply ignored and the subscription registers as a basic one.

Source

fn create_subscription_for_topic<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, ) -> NodeResult<NodeSubscription<'entity, M>>

Declare a subscription using topic as both the stable entity ID and callback ID.

Source

fn create_subscription_for_topic_with_qos<'entity, M: MessageForRmw>( &mut self, topic: &'entity str, qos: QoSProfile, ) -> NodeResult<NodeSubscription<'entity, M>>

Declare a subscription with explicit QoS, using topic as both IDs.

Source

fn create_subscription_static<M: MessageForRmw>( &mut self, topic: &'static str, ) -> NodeResult<SubscriptionTag>

Declare a subscription whose stable entity and callback IDs are both synthesized from the topic literal, returning a SubscriptionTag the Node author stores on Self::State and matches against the Callback<'_> delivered to ExecutableNode::on_callback.

Use this on the Phase 216.A Deferred Node path where the Node author does not need to invent a separate stable entity ID — the topic literal becomes both the entity ID and the callback ID, and the returned tag preserves that identifier for compile-time state.sub_chatter == cb matches in on_callback.

Source

fn create_timer_for_callback_name<'callback>( &mut self, callback_name: &'callback str, period: TimerDuration, ) -> NodeResult<NodeTimer<'callback>>

Declare a timer using callback_name as the source callback name and synthesized entity ID.

Source

fn create_timer_for_callback_name_on_clock<'callback>( &mut self, callback_name: &'callback str, period: TimerDuration, clock: TimerClockSource, ) -> NodeResult<NodeTimer<'callback>>

declare_timer_on_clock using callback_name as the source callback name and synthesized entity ID — the spelling a nros::main! component writes:

ⓘ
node.create_timer_for_callback_name_on_clock(
    "on_tick",
    TimerDuration::from_millis(100),
    TimerClockSource::Ros,
)?;
Source

fn create_service_server_for_name<'entity, S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeServiceServer<'entity, S>>

Declare a service server using name as both the stable entity ID and callback ID.

Source

fn create_service_server_for_name_with_callback<'entity, S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'entity str, callback_name: &str, ) -> NodeResult<NodeServiceServer<'entity, S>>

Declare a service server using name as the stable entity ID and callback_name as the source callback name.

Source

fn create_service_static<S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'static str, ) -> NodeResult<ServiceTag>

Declare a service server whose stable entity and callback IDs are both synthesized from the service-name literal, returning a ServiceTag the Node author stores on Self::State and matches against the Callback<'_> delivered to ExecutableNode::on_callback.

Tag-only registration is restricted to the SERVER side: clients need a USABLE handle (NodeServiceClient) to issue requests, so use the existing create_service_client_for_name builder for the client side.

Source

fn create_service_client_for_name<'entity, S: RosService<Request: MessageForRmw, Reply: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeServiceClient<'entity, S>>

Declare a service client using name as the stable entity ID.

Source

fn create_action_server_for_name<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeActionServer<'entity, A>>

Declare an action server using name as the stable entity ID and default goal/cancel/accepted callback ID.

Source

fn create_action_server_for_name_with_callbacks<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, goal_callback_name: &str, cancel_callback_name: &str, accepted_callback_name: &str, ) -> NodeResult<NodeActionServer<'entity, A>>

Declare an action server using name as the stable entity ID and explicit source callback names for goal, cancel, and accepted events.

Source

fn create_action_static<A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'static str, ) -> NodeResult<ActionTag>

Declare an action server whose stable entity and callback IDs are both synthesized from the action-name literal, returning an ActionTag the Node author stores on Self::State and matches against the Callback<'_> delivered to ExecutableNode::on_callback.

The synthesized callback ID is shared by the goal / cancel / accepted callbacks (matching the default behavior of declare_action_server).

Tag-only registration is restricted to the SERVER side: clients need a USABLE handle (NodeActionClient) to dispatch goals, so use the existing create_action_client_for_name builder for the client side.

Source

fn create_action_client_for_name<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, ) -> NodeResult<NodeActionClient<'entity, A>>

Declare an action client using name as the stable entity ID.

Source

fn create_action_client_with_callbacks_for_name<'entity, A: RosAction<Goal: MessageForRmw, Result: MessageForRmw, Feedback: MessageForRmw, SendGoalRequest: MessageForRmw, SendGoalResponse: MessageForRmw, GetResultRequest: MessageForRmw, GetResultResponse: MessageForRmw, FeedbackMessage: MessageForRmw>>( &mut self, name: &'entity str, result_callback_name: &str, feedback_callback_name: &str, ) -> NodeResult<NodeActionClient<'entity, A>>

Declare an action client that delivers the goal RESULT + FEEDBACK to named callbacks (Phase 212.M-F.23). name is the stable entity ID. The executor auto-drives accept → feedback stream → result during spin and dispatches ExecutableNode::on_callback with result_callback_name (payload = result CDR) on completion, and with feedback_callback_name (payload = feedback CDR) per feedback message. Read either with CallbackCtx::message::<A::Result>() / ::<A::Feedback>(). Without these the client can only send_goal; result + feedback are dropped.

(Layout note: the action-client variant reuses the server-side action_accepted_callback_id metadata slot for the feedback callback — that field is unused on a client, so no new schema field is needed.)

Source

fn declare_parameter_for_name<'entity>( &mut self, name: &'entity str, parameter_type: ParameterType, ) -> NodeResult<NodeParameter<'entity>>

Declare a parameter using name as the generated stable entity ID.

Source

fn declare_parameter_for_name_with_default<'entity>( &mut self, name: &'entity str, default: ParameterDefault, ) -> NodeResult<NodeParameter<'entity>>

Declare a parameter with a concrete source default, using name as the generated stable entity ID.

Source

fn callback_for_name<'callback>( &mut self, name: &'callback str, ) -> CallbackEffects<'_, 'callback>

Record optional effects for a named callback without exposing CallbackId at the declaration site.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl DeclarativeNode for Node<'_, 'static>

Available on crate feature rmw-cffi only.