zenkey 0.7.0

Executable form of the keyspace-v2 Zenoh semantic convention: typed key grammar, origin minting, slugs, QoS profiles, registry slices
Documentation
//! 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):
//!
//! ```text
//! 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).
//! - [`mod@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.

// docs.rs builds on nightly with `--cfg docsrs` (see Cargo.toml), which is
// what lets each feature-gated item carry the feature that gates it. Inert
// everywhere else — a stable `cargo doc` never sets the cfg (#325).
//
// **This is inferred, not annotated.** `doc_auto_cfg` was removed in Rust
// 1.92 (rust-lang/rust#138907) by being folded into `doc_cfg`, so enabling
// the feature here labels *every* `#[cfg(feature = "…")]` item, nested
// modules included — verified against the nightly docs.rs uses by rendering
// `judge::doctor`, `bus::body`, `model::decode` and `tape::generate` and
// finding the badge on each. A hand-written
// `#[cfg_attr(docsrs, doc(cfg(…)))]` beside a `#[cfg(…)]` is therefore
// redundant, and a *wrong* one would render a lie; the ones still on the
// re-exports below predate the merge and are harmless.
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod alert;
pub mod common_state;
pub mod context;
pub mod encoding;
pub mod grammar;
pub mod key;
pub mod origin;
pub mod pattern;
pub mod profile;
pub mod qos;
#[cfg(feature = "schema")]
#[cfg_attr(docsrs, doc(cfg(feature = "schema")))]
pub mod schema;
pub mod selector;
pub mod slice;
pub mod slug;

pub use common_state::{CommonFamily, CommonState};
pub use context::{BlobProbePrefix, V1Context};
pub use encoding::WireEncoding;
pub use grammar::{
    BlobTier, Class, ClassOrPlane, ContentHash, KeyError, Origin, Plane, Position5, Producer,
    StructuralKey, VERSION_CHUNK,
};
/// Not public API — the reachable path generated registry code names to wrap
/// its own builder output (issue #312). Nothing here is covered by semver.
#[doc(hidden)]
pub use key::__private;
pub use key::{Chunk, Key, Selector};
pub use origin::{ConcreteOrigin, Fleet, HostId, LocalOrigin, RemoteOrigin, ServiceOrigin};
pub use profile::{AppName, AppProfile, OriginSalt};
pub use qos::QosProfile;
pub use slice::{
    Declared, Fanout, ProcedureKind, RateClass, RegistrySlice, SliceFinding, SliceToken,
    parse_slice, to_toml as slice_to_toml,
};

/// The crate README's first snippet, compiled (#324's aftermath).
///
/// It is the adoption example on the crates.io landing page, and it silently
/// stopped compiling when `AppProfile::new` took its two constants as
/// newtypes: nothing built it, so nothing said so. `#[cfg(doctest)]` means
/// the file is *tested* and never rendered — the crate docs stay as they
/// are, and the two illustrative blocks that reference an application's own
/// generated module are fenced `rust,ignore`, which is the honest label for
/// code that cannot be compiled here.
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;