Zenohex.KeyExpr (Zenohex v0.9.1-beta.1)

Copy Markdown View Source

Provides utility functions for working with Zenoh key expressions (keyexpr).

Key expressions in Zenoh define paths or patterns used to match resources. These utilities help manage their correctness and relationships.

Summary

Functions

Canonizes the key_expr.

Returns true if key_expr1 includes key_expr2.

Returns true if the keyexprs intersect.

Joins two key expressions, inserting a / between them.

Validate the key_expr.

Functions

canonize(key_expr)

@spec canonize(String.t()) :: {:ok, String.t()} | {:error, String.t()}

Canonizes the key_expr.

Examples

iex> Zenohex.KeyExpr.canonize("key/expr/**/*")
{:ok, "key/expr/*/**"}

includes?(key_expr1, key_expr2)

@spec includes?(String.t(), String.t()) :: boolean()

Returns true if key_expr1 includes key_expr2.

The set defined by key_expr1 contains every key belonging to the set defined by key_expr2.

intersects?(key_expr1, key_expr2)

@spec intersects?(String.t(), String.t()) :: boolean()

Returns true if the keyexprs intersect.

There exists at least one key which is contained in both of the sets defined by key_expr1 and key_expr2.

join(key_expr1, key_expr2)

@spec join(String.t(), String.t()) :: {:ok, String.t()} | {:error, String.t()}

Joins two key expressions, inserting a / between them.

Returns the resulting key expression string, canonized.

Examples

iex> Zenohex.KeyExpr.join("key/expr", "sub")
{:ok, "key/expr/sub"}

valid?(key_expr)

@spec valid?(String.t()) :: boolean()

Validate the key_expr.