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 ROSTER COVERAGE PROBE** — every storable type this crate ships has a [`ColumnEq`] row, and
//! the probe is a `const` so a missing row is a COMPILE error rather than a failing assertion.
//!
//! The shape is `column::stored::tests`'s `agree!`, one face over: a monomorphised function item in
//! a `const` initialiser discharges the bound, names nothing in any scope, and costs no runtime.
//!
//! # Why a probe at all, when the emitted fold would find a gap anyway
//!
//! It would — but only for a type some record in this workspace happens to store, and at the
//! declaration rather than at the row. A type this crate ships is storable whether or not anything
//! here stores one, and the day a citizen lands with a width and no sameness the report should name
//! the CITIZEN. That is what the lists below do, and it is why they are written out rather than
//! derived from the width table: a census whose entries are synthesised measures the synthesis.

use super::ColumnEq;

/// The bound, discharged at every type named below.
///
/// `?Sized` because `str` is on the roster and is the one entry that is not sized — its width row
/// exists, its `StoredAs` deliberately does not, and its sameness is a fact all the same.
const fn joins<T: ColumnEq + ?Sized>() {}

/// Every type in one list gains its `const`.
macro_rules! rostered {
  ($( $ty:ty ),+ $(,)?) => {
    $( const _: fn() = joins::<$ty>; )+
  };
}

// THE UNGATED CORE — `column.rs`'s own `column_eq!` list, read back.
rostered! {
  bool, i8, i16, i32, i64, u8, u16, u32, u64, i128, u128, f32, f64,
  str, String,
  smol_bytes::Utf8Bytes,
  uuid::Uuid,
  crate::BeU64, crate::BeU128, crate::BeI128,
  crate::Count,
  core::time::Duration,
  core::num::NonZeroI8, core::num::NonZeroI16, core::num::NonZeroI32, core::num::NonZeroI64,
  core::num::NonZeroI128,
  core::num::NonZeroU8, core::num::NonZeroU16, core::num::NonZeroU32, core::num::NonZeroU64,
  core::num::NonZeroU128,
  crate::Timestamp,
}

// THE WRAPPERS, at a concrete inner — a generic row is only a row where it can be INSTANTIATED, so
// each is probed at a type the roster above already carries.
rostered! {
  &str,
  Option<i64>,
  Option<String>,
  Vec<u8>,
  Vec<String>,
  Option<Vec<i64>>,
}

#[cfg(feature = "regex")]
rostered! { regex::Regex, Option<regex::Regex>, Vec<regex::Regex> }

#[cfg(feature = "time")]
rostered! { time::OffsetDateTime, time::PrimitiveDateTime, time::Date, time::Time }

#[cfg(all(feature = "postgres", feature = "jiff"))]
rostered! { crate::PgDuration }

#[cfg(feature = "postgres")]
rostered! { sqlx::postgres::types::PgInterval }

#[cfg(all(feature = "mysql", feature = "jiff"))]
rostered! { crate::MySqlDuration }

/// The `Option` row's two-state reading, which is the one wrapper whose answer is not simply its
/// inner's — absence is a value, and it is never a presence.
#[test]
fn absence_is_a_value_and_never_a_presence() {
  assert!(None::<i64>.column_eq(&None));
  assert!(Some(7i64).column_eq(&Some(7)));
  assert!(!Some(7i64).column_eq(&None));
  assert!(!None::<i64>.column_eq(&Some(7)));
}

/// A collection compares element-wise and IN ORDER, which is what an edge-stored column reads back.
#[test]
fn a_collection_compares_its_elements_in_order() {
  let one = vec!["a".to_owned(), "b".to_owned()];
  assert!(one.column_eq(&vec!["a".to_owned(), "b".to_owned()]));
  assert!(!one.column_eq(&vec!["b".to_owned(), "a".to_owned()]));
  assert!(!one.column_eq(&vec!["a".to_owned()]));
}

/// The contract is [`PartialEq`]'s where the row is `PartialEq`'s, so a PARTIAL equivalence stays
/// partial — `NaN` is a column value and is not the same value as itself.
#[test]
fn a_partial_equivalence_stays_partial() {
  assert!(!f64::NAN.column_eq(&f64::NAN));
  assert!(!Some(f32::NAN).column_eq(&Some(f32::NAN)));
  assert!(0.0f64.column_eq(&-0.0));
}