Skip to main content

NodeContext

Struct NodeContext 

Source
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>

Source

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).

Source

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.

Source

pub const fn component_name(&self) -> &'static str

Source component name.

Source

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.

Source

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”.

Source

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).

Source

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.

Source

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).

Source

pub fn count_publishers(&mut self, topic_name: &str) -> Result<usize, NodeError>

The graph’s publisher count on topic_name (not this node’s).

Source

pub fn count_subscriptions( &mut self, topic_name: &str, ) -> Result<usize, NodeError>

The graph’s subscription count on topic_name.

Source

pub fn count_clients(&mut self, service_name: &str) -> Result<usize, NodeError>

The graph’s client count on service_name.

Source

pub fn count_services(&mut self, service_name: &str) -> Result<usize, NodeError>

The graph’s server count on service_name.

Source

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).

Source

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).

Source

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).

Source

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).

Source

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.

Source

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.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !Send for NodeContext<'a>

§

impl<'a> !Sync for NodeContext<'a>

§

impl<'a> !UnwindSafe for NodeContext<'a>

§

impl<'a> Freeze for NodeContext<'a>

§

impl<'a> RefUnwindSafe for NodeContext<'a>

§

impl<'a> Unpin for NodeContext<'a>

§

impl<'a> UnsafeUnpin for NodeContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.