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 seam is HAND-WRITABLE, and its three seats project.
//!
//! What the macro emits is asserted off its tokens in `ingraph-codegen` and put through a real
//! compile by `ingraph/tests/tower_walk.rs`. What is here is the half neither of those can state:
//! that a tower nobody generated is a tower.

use super::{DeclaredTower, SearchTower, Step};

/// A tower written by hand — no macro, no `Serves` impl, no walk.
struct Rewrite;

/// Where its steps live, named separately from the tower to spend the [`SearchTower::Steps`] seat's
/// own freedom: the declaration is not obliged to BE its own steps struct.
struct RewriteSteps;

impl SearchTower for Rewrite {
  type Question = String;
  type Answer = String;
  type Steps = RewriteSteps;
}

/// What a consumer binds — the ends read through the projection rather than off the type.
fn ends<T: SearchTower>(question: T::Question) -> T::Question {
  question
}

/// A tower nobody generated selects under the bound, and its ends project.
#[test]
fn a_hand_written_tower_is_a_tower() {
  let asked: <Rewrite as SearchTower>::Question = "北京".to_owned();
  assert_eq!(ends::<Rewrite>(asked), "北京");
}

/// The steps seat is the STRUCT, and it is free of the declaration.
#[test]
fn the_steps_seat_names_where_the_servers_live() {
  let _: <Rewrite as SearchTower>::Steps = RewriteSteps;
}

/// The RECORD is hand-writable too, and its two constants are DEFAULTED — so a tower nobody
/// generated joins with two type lines and states the honest nothing at both clocks.
///
/// `()` at the REQUEST clock is the Rust-only road spelled out: the wire duty lands at a dressed
/// recipe and nowhere else, so a tower walked from Rust pays it nothing.
impl DeclaredTower for Rewrite {
  type StepOptions = ();
  type SearchOptions = ();
}

/// A hand-written record answers every question a reader can ask it.
#[test]
fn a_hand_written_tower_states_the_honest_nothing() {
  const {
    assert!(
      <Rewrite as DeclaredTower>::ALL_SYNC,
      "no awaited step was declared, which is what the default says"
    );
  }
  assert!(<Rewrite as DeclaredTower>::STEPS.is_empty());
  let _: <Rewrite as DeclaredTower>::StepOptions = ();
  let _: <Rewrite as DeclaredTower>::SearchOptions = ();
}

/// A ROSTER ROW is a `const` value anybody can build, which is what makes the record's table a
/// public vocabulary rather than the macro's private one.
#[test]
fn a_step_row_carries_the_name_and_the_face_word() {
  const ROSTER: &[Step] = &[Step::of("tokenize"), Step::of("encode").awaited()];

  assert_eq!(ROSTER[0].field(), "tokenize");
  assert!(!ROSTER[0].is_awaited(), "no word, the blocking face");
  assert_eq!(ROSTER[1].field(), "encode");
  assert!(ROSTER[1].is_awaited(), "the word beside the step, recorded");
}