ingraph-codegen 0.1.0

The emission engine behind ingraph-derive: a plain declaration model in, the ingraph framework faces out.
Documentation
//! THE FIVE BOUNDS AN ID OWES, read back out of a whole expansion.
//!
//! *强制* — *id有这些属性应该是必须的*. The obligation is instantiated beside the `Identifiable` impl
//! that names the id, as `const _: fn() = …::ids_are_keys::<Id>;`, and this file's subject is that
//! it is there and that it is there UNCONDITIONALLY.
//!
//! The whole expansion rather than one emitter, because unconditional is a claim about the
//! expansion: a record that stores nowhere, publishes no wire face and is never batched still owes
//! them, and the only way to say so is to render one of those and look.
//!
//! The single leg's own two lanes are `queries/batch_lane_tests.rs`, beside the emitter that writes
//! them.

use crate::tests::{emission, model, wired};

/// **THE FIVE BOUNDS ARE INSTANTIATED AT THE DECLARATION**, over the type the `Identifiable` impl
/// beside them names — carried VERBATIM, so an alias stays an alias here as it does everywhere else
/// in this emission.
///
/// `const _: fn() = …::<Id>;` is the shape [`super::relate`]'s forward `ref` equation already takes,
/// which is what makes it the right one: an obligation an expansion instantiates, refused at the
/// declaration that owes it rather than at whatever first tried to spend it.
#[test]
fn a_records_id_owes_the_five_bounds() {
  let emitted = prettyplease::unparse(&emission(&wired()));

  assert!(
    emitted.contains("transform::ids_are_keys::<Uuid7>"),
    "the obligation is instantiated over the declared id type:\n{emitted}"
  );
}

/// **AND IT IS UNCONDITIONAL** — because a mandate conditional on a consumer is not a mandate.
///
/// A bare model stores in no database and publishes no wire face, so nothing in its expansion could
/// ever ask a batch door for anything. It owes the five bounds all the same, and finds out at its
/// own `id` field rather than in whatever application first tried to batch it.
#[test]
fn even_a_record_that_stores_nowhere_owes_them() {
  let emitted = prettyplease::unparse(&emission(&model("Clip", &[], "id")));

  assert!(
    !emitted.contains("BatchDoor"),
    "the fixture has no wire face, so no door is named:\n{emitted}"
  );
  assert!(
    emitted.contains("ids_are_keys"),
    "and it owes the five bounds all the same:\n{emitted}"
  );
}

/// **ONCE PER RECORD**, beside the id it is about — not once per backend and not once per face.
///
/// The wired fixture stores in three databases and publishes a wire face; the obligation is the
/// RECORD's, so a build that compiles two dialects instantiates one bound rather than two.
#[test]
fn the_obligation_is_the_records_and_not_a_backends() {
  let emitted = prettyplease::unparse(&emission(&wired()));

  assert_eq!(
    emitted.matches("ids_are_keys").count(),
    1,
    "one obligation per record:\n{emitted}"
  );
}