Skip to main content

Crate zenkey

Crate zenkey 

Source
Expand description

Executable form of the keyspace-v2 convention.

The convention is specified in rfcs/ (v1). This crate is its enforcement layer: everything a producer or consumer needs to emit and parse conforming keys without ever spelling a raw key string.

Canonical grammar (base-relative — the deployment base is the session namespace, RFC 03 §1.1, so no key built here contains it):

v1/<origin>/<class>/<producer>/<subject...>

Layer map:

  • keyKey/Selector/Chunk: validated key value types over zenoh_keyexpr::OwnedKeyExpr (RFC 08 §1.2).
  • grammar — chunk lexical rules, reserved tokens, structural key assembly and parsing (RFC 03).
  • originh-<12hex> host-origin minting (RFC 06 §1).
  • profile — the application profile: app name + origin salt, the two constants an adopting application declares (RFC 06 §1, RFC 11 §4).
  • slug — canonical, injective slugging of foreign values (RFC 03 §2).
  • qos — the five named QoS profiles (RFC 04 §3).
  • contextV1Context: origin + producer; producers build all framework keys through it.
  • [slice] — RegistrySlice, the introspect reply type + diff (RFC 08 §6).

The subject vocabulary itself is governed by the registry (RFC 08). It is application-owned: each application checks its registry/*.toml into its own repository and generates typed subject builders/parsers from them with the zenkey-build crate in its build script. This crate ships no registry.

The RFC’s design properties D1–D6 are pinned as executable guard tests in tests/guard.rs — run by CI, as RFC 03 §4 requires.

§Note on the deployment base

There is deliberately no base constant in this crate. The base is the value a deployment sets as its Zenoh session namespace, which prefixes it onto every keyexpr the session emits, strips it on delivery, and filters ingress from outside it — an isolation boundary, not a string convention (RFC 09 §0). The only legitimate readers are session configuration, router-side artifacts (storage selectors, ACL rules), and deliberately un-namespaced debug tools (zenctl). Application code that reaches for a base to build a key has made a mistake: the session adds the base.

Re-exports§

pub use common_state::CommonState;
pub use context::V1Context;
pub use grammar::Class;
pub use grammar::ClassOrPlane;
pub use grammar::KeyError;
pub use grammar::Origin;
pub use grammar::Plane;
pub use grammar::Producer;
pub use grammar::StructuralKey;
pub use grammar::VERSION_CHUNK;
pub use key::Chunk;
pub use key::Key;
pub use key::Selector;
pub use origin::ConcreteOrigin;
pub use origin::Fleet;
pub use origin::HostId;
pub use origin::LocalOrigin;
pub use origin::RemoteOrigin;
pub use origin::ServiceOrigin;
pub use profile::AppProfile;
pub use qos::QosProfile;
pub use slice::RegistrySlice;
pub use slice::SliceFinding;
pub use slice::parse_slice;

Modules§

common_state
The framework state subjects, shared by every producer (issue #475).
context
The v1 keyspace context: origin + producer in one value.
grammar
Chunk lexical rules, reserved tokens, and structural key assembly/parsing.
key
Validated key types (RFC 08 §1.2, issue #5).
origin
Host-origin minting: h-<12hex> (RFC 06 §1).
pattern
Subject-pattern matching (RFC 08 §1/§2, issue #7).
profile
The application profile: the two constants an adopting application must choose, bundled with the once-per-process host-origin mint (RFC 06 §1, RFC 11 §4).
qos
The five named QoS profiles (RFC 04 §3). The profile vocabulary is closed; registry entries reference these by name and publishers set QoS only through them.
selector
Typed selectors (RFC 04/05 wire-observer surface, issue #7).
slice
RegistrySlice — the reply type of the introspect procedure (RFC 08 §6).
slug
Canonical, injective slugging of foreign values into key chunks (RFC 03 §2).