Skip to main content

entity_key

Function entity_key 

Source
pub fn entity_key(
    domain_id: u32,
    fqn: &str,
    ros_type: &str,
    hash: &TypeHash,
) -> Option<String>
Expand description

Builds the rmw_zenoh key expression for a ROS 2 topic or service.

§Arguments

  • domain_id - the ROS domain id (the ROS_DOMAIN_ID, default 0).
  • fqn - the fully qualified name (starting with /), for example /chatter.
  • ros_type - the interface type as package/namespace/Type, for example std_msgs/msg/String.
  • hash - the message TypeHash.

§Returns

Some(key) such as 0/chatter/std_msgs::msg::dds_::String_/RIHS01_...; None if fqn is not fully qualified, if ros_type is not a valid three-part interface type, or if the assembled key is somehow not a valid Zenoh key expression.

§Examples

use pamoja_ros2::key::entity_key;
use pamoja_ros2::typehash::TypeHash;

let hash =
    TypeHash::parse("RIHS01_df668c740482bbd48fb39d76a70dfd4bd59db1288021743503259e948f6b1a18")
        .unwrap();
let key = entity_key(0, "/chatter", "std_msgs/msg/String", &hash).unwrap();
assert_eq!(
    key,
    "0/chatter/std_msgs::msg::dds_::String_/RIHS01_df668c740482bbd48fb39d76a70dfd4bd59db1288021743503259e948f6b1a18",
);