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
//! The currency bound, read at the two widths it exists to tell apart.
//!
//! The refusal a currency with NO crossing row earns is a compile-level claim and is pinned as a
//! `compile_fail` doctest on [`WireScore`](super::WireScore) itself: this module is `cfg(test)`, so
//! rustdoc never reads it, and a doctest written here would be a pin that never runs.

use async_graphql::OutputType;

use super::WireScore;

/// The WIDTH a score renders at, taken through the bound rather than through the map — so what is
/// asserted is what a hit's face will actually publish.
fn width<S: WireScore>() -> String {
  <<S as WireScore>::Wire<'static> as OutputType>::type_name().into_owned()
}

/// **THE TWO FLOAT WIDTHS ARE TWO SCHEMA TYPES AT THE SCORE SEAT.** The suite's own claim, read
/// where it had not reached: async-graphql publishes `f32` and `f64` both as `Float`, so a score
/// bound `OutputType` said `Float` at either width.
#[test]
fn a_score_renders_the_width_its_engine_measures_in() {
  assert_eq!(width::<f32>(), "f32");
  assert_eq!(width::<f64>(), "f64");
  assert_ne!(width::<f32>(), width::<f64>());
  // …and the bare Rust face is UNTOUCHED, which is what "binding-scoped" means here too: the width
  // is named where a value CROSSES and nowhere before it.
  assert_eq!(<f32 as OutputType>::type_name(), "Float");
  assert_eq!(<f64 as OutputType>::type_name(), "Float");
}

/// **A CURRENCY OF SOMEBODY'S OWN REACHES THE SEAT THROUGH ITS OWN ROW**, at whatever width it
/// declared — which is why the seat is the crossing rather than a fixed float.
#[test]
fn an_integer_currency_crosses_at_its_own_width() {
  assert_eq!(width::<u64>(), "u64");
  assert_eq!(width::<i32>(), "i32");
  assert_eq!(width::<u128>(), "u128");
  // The framework's own confidence crosses at the WIDTH it measures in, and the name is the
  // roster's rather than one of its own: the four `Score*` scalars are retired, so a confidence
  // currency and an `f32` currency publish one type — which is the seat's whole claim read at the
  // one currency this crate declares.
  assert_eq!(width::<crate::Score>(), "f32");
  assert_eq!(width::<crate::Confidence<f64>>(), "f64");
}

/// **THE VALUE ITSELF SURVIVES THE CROSSING**, which is the half a `type_name` assertion cannot
/// show: the row hands back the score it was given, in the carrier.
#[test]
fn the_crossing_carries_the_value_and_not_only_its_name() {
  assert_eq!(
    <f32 as WireScore>::wire_score(&0.5_f32),
    crate::F32::from(0.5_f32),
  );
  assert_eq!(
    <u64 as WireScore>::wire_score(&u64::MAX),
    crate::U64::from(u64::MAX),
  );
}