Skip to main content

is_valid

Function is_valid 

Source
pub fn is_valid(ke: &str) -> bool
Expand description

Returns whether a string is a well-formed key expression.

A well-formed expression may still need canonize before a Zenoh session accepts it; see is_canon.

§Arguments

  • ke - the candidate key expression.

§Returns

true if ke is /-joined non-empty chunks with no leading, trailing, or doubled /, where each chunk is *, **, or a literal in which * appears only as part of $* and $ only before *, with no ? or #.

§Examples

use pamoja_zenoh::keyexpr::is_valid;

assert!(is_valid("fleet/*/battery"));
assert!(is_valid("fleet/**/**/battery")); // well formed, though not yet canonical
assert!(!is_valid("fleet//battery")); // an empty chunk
assert!(!is_valid("fleet/n7*")); // `*` inside a chunk is legal only as `$*`