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:

  • key — Key/Selector/Chunk: validated key value types over zenoh_keyexpr::OwnedKeyExpr (RFC 08 §1.2).
  • alert — the alert-key derivation, byte-precise (RFC 11 §3.1 — the reference profile’s binding of RFC 04 §1.2’s neutral requirement).
  • grammar — chunk lexical rules, reserved tokens, structural key assembly and parsing (RFC 03); ContentHash, the validated digest type that makes @blob Tier-2 content-addressing structural (RFC 07 §2.3, v1.7).
  • origin — h-<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).
  • context — V1Context: origin + producer; producers build all framework keys through it. BlobProbePrefix, the *-origin @blob probe form — deliberately not a Key, so a probe cannot be passed where a fetch prefix is expected (RFC 07 §2.5/§3).
  • slice — RegistrySlice, the introspect reply type + diff (RFC 08 §6).
  • registry_doc — the registry file as a document in either spelling, TOML or KDL (SliceFormat, RFC 08 §5.1, v1.44), and the §6 negotiation on a reply’s declared Encoding (registry_doc::negotiate).
  • config — the configuration convention’s wire shapes and validator (RFC 05 §5.1, v1.42): schema, groups, classes, the change request, the read-back, the change event, Sensitive.

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::CommonFamily;
pub use common_state::CommonState;
pub use context::BlobProbePrefix;
pub use context::V1Context;
pub use encoding::WireEncoding;
pub use grammar::BlobTier;
pub use grammar::Class;
pub use grammar::ClassOrPlane;
pub use grammar::ContentHash;
pub use grammar::KeyError;
pub use grammar::Origin;
pub use grammar::Plane;
pub use grammar::Position5;
pub use grammar::Producer;
pub use grammar::StructuralKey;
pub use grammar::VERSION_CHUNK;
pub use key::Chunk;
pub use key::ExactKeyError;
pub use key::Key;
pub use key::Selector;
pub use key::require_exact;
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::AppName;
pub use profile::AppProfile;
pub use profile::OriginSalt;
pub use qos::QosProfile;
pub use registry_doc::SliceFormat;
pub use slice::Bound;
pub use slice::Buckets;
pub use slice::Declared;
pub use slice::ErrorDecl;
pub use slice::Exposure;
pub use slice::Fanout;
pub use slice::Predicate;
pub use slice::PredicateKind;
pub use slice::ProcedureKind;
pub use slice::RateClass;
pub use slice::RegistrySlice;
pub use slice::Semantic;
pub use slice::SliceFinding;
pub use slice::SliceToken;
pub use slice::SubjectKind;
pub use slice::parse_served;
pub use slice::parse_slice;
pub use slice::parse_slice_as;
pub use slice::to_kdl as slice_to_kdl;
pub use slice::to_toml as slice_to_toml;
pub use slice::toml_quote;

Modules§

alert
The alert-key derivation — the ZenSight reference recipe (RFC 11 §3.1).
common_state
The framework state subjects, shared by every producer (issue #475).
config
The configuration convention (RFC 05 §5.1, v1.42): the wire shapes a producer’s configuration plane serves and a consumer reads, and the one validator every producer applies before its device sees a change.
context
The v1 keyspace context: origin + producer in one value.
encoding
WireEncoding — how a payload is framed on the wire.
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.
registry_doc
The registry file as a document, in either of its two spellings (RFC 08 §5.1, v1.44; #374).
rpc_error
The @rpc error vocabulary (RFC 05 §3): the names every conforming caller understands, and the shape of a producer’s own.
schemaschema
Payload self-description (RFC 08 §7, issue #11) — feature schema.
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).