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
use core::convert::Infallible;

use super::{FromFilter, TryFromFilter};
use crate::ScalarFilter;

/// Stands in for a comparison declared OUTSIDE this crate: it implements the short half only, which
/// is the arrangement the blanket exists to serve.
#[derive(Debug, PartialEq)]
struct Downstream(Option<i64>);

impl FromFilter<ScalarFilter<i64>> for Downstream {
  fn from_filter(filter: ScalarFilter<i64>) -> Self {
    Self(filter.eq)
  }
}

#[test]
fn the_short_half_supplies_the_long_one() {
  let filter = ScalarFilter::new().with_eq(7i64);
  let crossed = Downstream::try_from_filter(filter).unwrap();
  assert_eq!(crossed, Downstream(Some(7)));
}

#[test]
fn a_crossing_that_cannot_fail_says_so_in_its_type() {
  // The assignment is the assertion: an error type that is not `Infallible` does not compile here,
  // so "always `Ok`" and "cannot be `Err`" stay distinguishable.
  fn error_of<C: TryFromFilter<F>, F>(_: &C, _: &F) -> core::marker::PhantomData<C::Error> {
    core::marker::PhantomData
  }

  let filter = ScalarFilter::new().with_eq(7i64);
  let crossed = Downstream::try_from_filter(ScalarFilter::new().with_eq(7i64)).unwrap();
  let _: core::marker::PhantomData<Infallible> = error_of(&crossed, &filter);
}