Key Expr
Address space
Zenoh's address space is designed around keys which serve as the names of resources.
Keys are slash-separated lists of non-empty UTF8 strings. They may not contain the following characters: $*#?
.
Zenoh's operations are executed on key expressions, a small language that allows the definition of sets of keys via the use of wildcards:
*
is the single-chunk wildcard, and will match any chunk:a/*/c
will matcha/b/c
,a/hello/c
, etc...**
is the 0 or more chunks wildcard:a/**/c
matchesa/c
,a/b/c
,a/b/hello/c
, etc...$*
is the sub-chunk wildcard, it will match any amount of non-/ characters:a/b$*
matchesa/b
,a/because
,a/blue
... but nota/c
nora/blue/c
To allow for better performance and gain the property that two key expressions define the same set if and only if they are the same string, the rules of canon form are mandatory for a key expression to be propagated by a Zenoh network:
**/**
may not exist, as it could always be replaced by the shorter**
,** /*
may not exist, and must be written as its equivalent*/**
instead,$*
may not exist alone in a chunk, as it must be written*
instead.
The KeyExpr.autocanonize
constructor exists to correct eventual infringements of the canonization rules.
A KeyExpr is a string that has been validated to be a valid Key Expression.
Declaring a key expression from a session.
A KeyExpr acts as a container for the string representation of a key expression. Operations like intersects
, includes
, and equals
are processed at the native layer using this string representation. For improved performance, consider initializing a KeyExpr through Session.declareKeyExpr. This method associates the KeyExpr with a native instance, thereby optimizing operation execution.
For more information, checkout the key expressions RFC.
Functions
Intersects operation.
Returns the relation between 'this' and other
from 'this''s point of view (SetIntersectionLevel::Includes
signifies that this
includes other). Note that this is slower than intersects and includes, so you should favor these methods for most applications.