Class KeyExpression
The naming rules a Zenoh network addresses data by.
public static class KeyExpression
- Inheritance
-
KeyExpression
- Inherited Members
Remarks
A key expression is a slash-separated path that may carry the * and
** wildcards, so one subscriber names a whole subtree of a fleet rather
than each node in it. A chunk that starts with @ is verbatim, and no
wildcard selects it. Only the naming rules cross: running a Zenoh session
needs the std-only zenoh stack, which stays in the Rust crate.
Methods
Canonize(string)
Rewrites a key expression into its canonical form.
public static string? Canonize(string key)
Parameters
keystringThe expression to canonize.
Returns
- string
The canonical form, or
nullif the expression is malformed.
Remarks
Two expressions that select the same data have one canonical form, so canonizing before comparing or routing keeps equivalent expressions equal.
Includes(string, string)
Reports whether one key expression selects every key another selects.
public static bool Includes(string a, string b)
Parameters
astringThe expression that may be the wider one.
bstringThe expression tested for being covered by
a.
Returns
- bool
truewhen every keybselects is also selected bya, orfalseif not or either expression is malformed.
Intersects(string, string)
Reports whether two key expressions share at least one key.
public static bool Intersects(string a, string b)
Parameters
Returns
- bool
truewhen some key is selected by both, orfalseif none is or either expression is malformed.
Remarks
This is the relation Zenoh routes by: a publication on one reaches a subscriber on the other exactly when the two intersect.
IsCanon(string)
Reports whether a key expression is already canonical.
public static bool IsCanon(string key)
Parameters
keystringThe expression to check.
Returns
- bool
truewhen the expression is canonical.
Remarks
The canonical form is the only one a Zenoh session accepts.
IsValid(string)
Reports whether a key expression is well formed.
public static bool IsValid(string key)
Parameters
keystringThe expression to check.
Returns
- bool
truewhen the expression is valid.
Join(string, string)
Joins two key expressions with a slash and canonizes the result.
public static string? Join(string prefix, string suffix)
Parameters
Returns
- string
The joined expression in canonical form, or
nullif either side is empty or the joined expression is malformed.
Matches(string, string)
Reports whether a pattern selects a concrete key.
public static bool Matches(string pattern, string key)
Parameters
patternstringThe expression that may carry wildcards.
keystringThe concrete key to test against it.
Returns
- bool
truewhen the pattern selects the key.