pub struct NodeContext<'a> { /* private fields */ }Expand description
Node declaration context — what a component’s
register receives.
It creates REAL nodes. create_node
returns a crate::Node, the same type Executor::create_node gives a
standalone program, so a component’s node code and a program’s node code
are one code. The component-only declarations are the
DeclarativeNode methods on that node.
Implementations§
Source§impl<'a> NodeContext<'a>
impl<'a> NodeContext<'a>
Sourcepub fn set_params(&mut self, params: &'a [(&'a str, &'a str)])
pub fn set_params(&mut self, params: &'a [(&'a str, &'a str)])
Seed this node instance’s baked launch parameters (called by
install_node_typed_with_params before Component::register).
Sourcepub fn param(&self, name: &str) -> Option<&'a str>
pub fn param(&self, name: &str) -> Option<&'a str>
The baked initial value of launch parameter name, or
None if the launch declared no <param name="…"/> for this node
instance. Read in register() and parse/stash on State.
Sourcepub const fn component_name(&self) -> &'static str
pub const fn component_name(&self) -> &'static str
Source component name.
Sourcepub fn create_node<'o>(
&mut self,
options: impl IntoNodeOptions<'o>,
) -> NodeResult<Node<'_, 'static>>
pub fn create_node<'o>( &mut self, options: impl IntoNodeOptions<'o>, ) -> NodeResult<Node<'_, 'static>>
Create this component’s node — rclrs’s executor.create_node(options).
The node’s name is the launch file’s when it names one, otherwise
options.name, which is also the component-stable node id the
declarations are keyed on.
Takes rclrs’s impl IntoNodeOptions, so
context.create_node("talker") reads as rclrs does. Unlike the
executor’s, a component’s options are applied as written.
Source§impl NodeContext<'_>
phase-572 W2 – the graph queries at registration. The context holds the
executor for the whole of register(), so each query is that executor’s
own call. At boot the graph is mostly not discovered yet: an early answer
is partial, never an error.
impl NodeContext<'_>
phase-572 W2 – the graph queries at registration. The context holds the
executor for the whole of register(), so each query is that executor’s
own call. At boot the graph is mostly not discovered yet: an early answer
is partial, never an error.
Sourcepub fn get_node_names(
&mut self,
visit: &mut dyn FnMut(&str, &str) -> bool,
) -> Result<(), NodeError>
pub fn get_node_names( &mut self, visit: &mut dyn FnMut(&str, &str) -> bool, ) -> Result<(), NodeError>
Every node on the graph: visit(name, namespace), stop on false.
What has been DISCOVERED, never blocking: empty means “not seen
yet”.
Sourcepub fn get_node_names_with_enclaves(
&mut self,
visit: &mut dyn FnMut(&str, &str, Option<&str>) -> bool,
) -> Result<(), NodeError>
pub fn get_node_names_with_enclaves( &mut self, visit: &mut dyn FnMut(&str, &str, Option<&str>) -> bool, ) -> Result<(), NodeError>
Every node with its enclave: visit(name, namespace, enclave).
Sourcepub fn get_topic_names_and_types(
&mut self,
visit: &mut dyn FnMut(&str, &[&str]) -> bool,
) -> Result<(), NodeError>
pub fn get_topic_names_and_types( &mut self, visit: &mut dyn FnMut(&str, &[&str]) -> bool, ) -> Result<(), NodeError>
Every topic with its types: visit(topic, types) once per topic.
Sourcepub fn get_service_names_and_types(
&mut self,
visit: &mut dyn FnMut(&str, &[&str]) -> bool,
) -> Result<(), NodeError>
pub fn get_service_names_and_types( &mut self, visit: &mut dyn FnMut(&str, &[&str]) -> bool, ) -> Result<(), NodeError>
Every service with its types: visit(service, types).
Sourcepub fn count_publishers(&mut self, topic_name: &str) -> Result<usize, NodeError>
pub fn count_publishers(&mut self, topic_name: &str) -> Result<usize, NodeError>
The graph’s publisher count on topic_name (not this node’s).
Sourcepub fn count_subscriptions(
&mut self,
topic_name: &str,
) -> Result<usize, NodeError>
pub fn count_subscriptions( &mut self, topic_name: &str, ) -> Result<usize, NodeError>
The graph’s subscription count on topic_name.
Sourcepub fn count_clients(&mut self, service_name: &str) -> Result<usize, NodeError>
pub fn count_clients(&mut self, service_name: &str) -> Result<usize, NodeError>
The graph’s client count on service_name.
Sourcepub fn count_services(&mut self, service_name: &str) -> Result<usize, NodeError>
pub fn count_services(&mut self, service_name: &str) -> Result<usize, NodeError>
The graph’s server count on service_name.
Sourcepub fn get_publisher_names_and_types_by_node(
&mut self,
node_name: &str,
node_namespace: &str,
visit: &mut dyn FnMut(&str, &[&str]) -> bool,
) -> Result<(), NodeError>
pub fn get_publisher_names_and_types_by_node( &mut self, node_name: &str, node_namespace: &str, visit: &mut dyn FnMut(&str, &[&str]) -> bool, ) -> Result<(), NodeError>
The topics a node publishes: visit(topic, types).
Sourcepub fn get_subscription_names_and_types_by_node(
&mut self,
node_name: &str,
node_namespace: &str,
visit: &mut dyn FnMut(&str, &[&str]) -> bool,
) -> Result<(), NodeError>
pub fn get_subscription_names_and_types_by_node( &mut self, node_name: &str, node_namespace: &str, visit: &mut dyn FnMut(&str, &[&str]) -> bool, ) -> Result<(), NodeError>
The topics a node subscribes to: visit(topic, types).
Sourcepub fn get_service_names_and_types_by_node(
&mut self,
node_name: &str,
node_namespace: &str,
visit: &mut dyn FnMut(&str, &[&str]) -> bool,
) -> Result<(), NodeError>
pub fn get_service_names_and_types_by_node( &mut self, node_name: &str, node_namespace: &str, visit: &mut dyn FnMut(&str, &[&str]) -> bool, ) -> Result<(), NodeError>
The services a node serves: visit(service, types).
Sourcepub fn get_client_names_and_types_by_node(
&mut self,
node_name: &str,
node_namespace: &str,
visit: &mut dyn FnMut(&str, &[&str]) -> bool,
) -> Result<(), NodeError>
pub fn get_client_names_and_types_by_node( &mut self, node_name: &str, node_namespace: &str, visit: &mut dyn FnMut(&str, &[&str]) -> bool, ) -> Result<(), NodeError>
The services a node is a client of: visit(service, types).
Sourcepub fn get_publishers_info_by_topic(
&mut self,
topic_name: &str,
visit: &mut dyn FnMut(&GraphEndpointInfo<'_>) -> bool,
) -> Result<(), NodeError>
pub fn get_publishers_info_by_topic( &mut self, topic_name: &str, visit: &mut dyn FnMut(&GraphEndpointInfo<'_>) -> bool, ) -> Result<(), NodeError>
The publishers on topic_name, one visit each.
Sourcepub fn get_subscriptions_info_by_topic(
&mut self,
topic_name: &str,
visit: &mut dyn FnMut(&GraphEndpointInfo<'_>) -> bool,
) -> Result<(), NodeError>
pub fn get_subscriptions_info_by_topic( &mut self, topic_name: &str, visit: &mut dyn FnMut(&GraphEndpointInfo<'_>) -> bool, ) -> Result<(), NodeError>
The subscriptions on topic_name, one visit each.
Trait Implementations§
Source§impl Drop for NodeContext<'_>
Available on crate feature rmw-cffi only.
impl Drop for NodeContext<'_>
rmw-cffi only.