ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
//! [`LaneIdent`] — one lane's key, as a type a value cannot be passed as.

use crate::name::borrowed_name;

#[cfg(test)]
mod tests;

borrowed_name! {
  /// ONE LANE'S KEY — the opaque word a backend block wrote, carried through the neutral layer
  /// without being read.
  ///
  /// # It is OPAQUE, and that is the ruling rather than laziness
  ///
  /// A lane exists because one engine has a physics — a field has a tokenizer, a schema is
  /// immutable — so the ruling that created it put the vocabulary INSIDE that engine's own block and
  /// gave the neutral layer exactly one new thing: a slot publishes a roster of these. Path
  /// validation, boot checks and merge provenance all ask the roster; none of them parses the block
  /// it came from, and none of them knows what the word means.
  ///
  /// So what a reader may do with one is compare it, hash it, print it and hand it back. What no
  /// reader may do is decide something from its SHAPE — that a two-letter word is a language, that a
  /// four-letter one is a script — because the party that wrote it is the only one that knows.
  ///
  /// # It validates NOTHING, and its neighbour does
  ///
  /// [`FieldName`](crate::FieldName)'s own posture, for the same reason: every string is a legal
  /// lane key as far as this layer is concerned, so there is no check to write here. What DOES
  /// decide whether a word can ever be reached is [`LanguageTag`](super::LanguageTag), one seam
  /// over — a key nothing reduces to is a key no tag arrives at, and that is a fact about the gate
  /// rather than about the identifier.
  ///
  /// # It costs nothing
  ///
  /// `#[repr(transparent)]` over `str` and holding nothing else, so `&LaneIdent` is a `&str` at the
  /// ABI and [`new`](Self::new) is a VIEW rather than a conversion. It is unsized for the reason
  /// `str` is, which is why it carries neither [`Clone`] nor [`Copy`]: what a caller holds is the
  /// borrow, and a roster is `&'static [Lane]` for exactly that reason.
  ///
  /// An OWNED lane word — one a refusal carries out of the gate — is
  /// [`Utf8Bytes`](smol_bytes::Utf8Bytes), which is this workspace's text carrier and the one an
  /// error may hold past the borrow that produced it. See [`UnknownLane`](super::UnknownLane).
  pub struct LaneIdent;
}

impl LaneIdent {
  /// **THE ZERO-CONFIGURATION LANE** — `und`, BCP-47's own *undetermined* primary subtag.
  ///
  /// A declaration that names no lanes has ONE, and this is its key. That keeps every reader
  /// uniform: there is no *is this corpus fanned* fork anywhere, because an unfanned corpus is a
  /// fanned one whose roster has a single entry — which is what
  /// [`Lanes::LANES`](super::Lanes::LANES)' default says in one line.
  ///
  /// The standard's own word rather than one invented here, on
  /// [`WritingSystem::Zzzz`](crate::WritingSystem::Zzzz)'s reasoning exactly: a vocabulary that already has a name
  /// for *this is not determined* is a vocabulary whose name should be used.
  pub const UND: &'static Self = Self::new("und");

  /// View `key` as a lane key.
  ///
  /// `const`, so a roster known at compile time can be built in a constant — which is where a
  /// declaration's lanes actually are.
  ///
  /// It refuses nothing, per the type's own note: the neutral layer does not read this word.
  #[inline]
  #[must_use]
  pub const fn new(key: &str) -> &Self {
    Self::view(key)
  }

  /// This key as a `str`.
  ///
  /// Beside [`Deref`](core::ops::Deref) and [`AsRef`](core::convert::AsRef) rather than instead of
  /// them, and it earns its place by being `const`: a roster is a `const`, its collision audit is
  /// spent AT THE DECLARATION, and neither trait road is callable in a constant.
  #[inline]
  #[must_use]
  pub const fn as_str(&self) -> &str {
    &self.0
  }
}