zenkey/lib.rs
1//! Executable form of the keyspace-v2 convention.
2//!
3//! The convention is specified in `rfcs/` (v1). This crate is
4//! its enforcement layer: everything a producer or consumer needs to emit and
5//! parse conforming keys without ever spelling a raw key string.
6//!
7//! Canonical grammar (base-relative — the deployment base is the session
8//! *namespace*, RFC 03 §1.1, so no key built here contains it):
9//!
10//! ```text
11//! v1/<origin>/<class>/<producer>/<subject...>
12//! ```
13//!
14//! Layer map:
15//! - [`key`] — [`Key`]/[`Selector`]/[`Chunk`]: validated key value types over
16//! `zenoh_keyexpr::OwnedKeyExpr` (RFC 08 §1.2).
17//! - [`grammar`] — chunk lexical rules, reserved tokens, structural key
18//! assembly and parsing (RFC 03).
19//! - [`origin`] — `h-<12hex>` host-origin minting (RFC 06 §1).
20//! - [`profile`] — the application profile: app name + origin salt, the two
21//! constants an adopting application declares (RFC 06 §1, RFC 11 §4).
22//! - [`slug`] — canonical, injective slugging of foreign values (RFC 03 §2).
23//! - [`qos`] — the five named QoS profiles (RFC 04 §3).
24//! - [`context`] — [`V1Context`]: origin + producer; producers build all
25//! framework keys through it.
26//! - [`slice`] — [`RegistrySlice`], the `introspect` reply type + diff
27//! (RFC 08 §6).
28//!
29//! The subject vocabulary itself is governed by the registry (RFC 08). It is
30//! **application-owned**: each application checks its `registry/*.toml` into
31//! its own repository and generates typed subject builders/parsers from them
32//! with the `zenkey-build` crate in its build script. This crate ships no
33//! registry.
34//!
35//! The RFC's design properties D1–D6 are pinned as executable guard tests in
36//! `tests/guard.rs` — run by CI, as RFC 03 §4 requires.
37//!
38//! # Note on the deployment base
39//!
40//! There is deliberately no base constant in this crate. The base is the value
41//! a deployment sets as its Zenoh session **`namespace`**, which prefixes it
42//! onto every keyexpr the session emits, strips it on delivery, and *filters*
43//! ingress from outside it — an isolation boundary, not a string convention
44//! (RFC 09 §0). The only legitimate readers are session configuration,
45//! router-side artifacts (storage selectors, ACL rules), and deliberately
46//! un-namespaced debug tools (`zenctl`). Application code that reaches for a
47//! base to *build a key* has made a mistake: the session adds the base.
48
49pub mod common_state;
50pub mod context;
51pub mod grammar;
52pub mod key;
53pub mod origin;
54pub mod pattern;
55pub mod profile;
56pub mod qos;
57#[cfg(feature = "schema")]
58pub mod schema;
59pub mod selector;
60pub mod slice;
61pub mod slug;
62
63pub use common_state::CommonState;
64pub use context::V1Context;
65pub use grammar::{
66 Class, ClassOrPlane, KeyError, Origin, Plane, Producer, StructuralKey, VERSION_CHUNK,
67};
68pub use key::{Chunk, Key, Selector};
69pub use origin::{ConcreteOrigin, Fleet, HostId, LocalOrigin, RemoteOrigin, ServiceOrigin};
70pub use profile::AppProfile;
71pub use qos::QosProfile;
72pub use slice::{RegistrySlice, SliceFinding, parse_slice};