Skip to main content

join

Function join 

Source
pub fn join(prefix: &str, suffix: &str) -> Option<String>
Expand description

Joins two key expressions with a / and returns the canonical form of the result.

This is how a key is built under a prefix, such as a node’s own subtree of a fleet, without spelling the separator by hand or leaving a non-canonical pair of wildcards at the seam.

§Arguments

  • prefix - the leading key expression.
  • suffix - the key expression to place beneath it.

§Returns

Some(joined) in canonical form; None if either side is empty or the joined expression is not valid.

§Examples

use pamoja_zenoh::keyexpr::join;

assert_eq!(join("fleet/n7", "battery").as_deref(), Some("fleet/n7/battery"));
assert_eq!(join("fleet/**", "*").as_deref(), Some("fleet/*/**")); // canonized at the seam
assert_eq!(join("fleet/", "battery"), None); // the seam would be an empty chunk