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 super::Connected;

// A stand-in connection-manager: what a `*Store` is once opened, reached by every op that borrows it.
struct Manager {
  root: &'static str,
}

/// The two halves are reached independently, and the connection is a BORROW while the scope is
/// OWNED — which is the split that lets one manager serve every call without being moved into any.
#[test]
fn a_bundle_hands_back_both_halves() {
  let manager = Manager { root: "/var/blobs" };
  let ctx = Connected::new(&manager, 7u32);

  assert_eq!(ctx.connection().root, "/var/blobs");
  assert_eq!(*ctx.scope(), 7);
  assert_eq!(ctx.into_scope(), 7);
}

/// `into_parts` yields the connection at the FULL outer lifetime rather than at a `&self` reborrow,
/// which is the property an impl holding the borrow across an await depends on. The assertion is the
/// binding itself: `conn` outlives the `ctx` it came from, so this only compiles if the lifetime is
/// the connection's and not the wrapper's.
#[test]
fn the_connection_survives_the_bundle_it_came_from() {
  let manager = Manager { root: "/srv" };
  let (conn, scope): (&Manager, ()) = Connected::new(&manager, ()).into_parts();

  assert_eq!(conn.root, "/srv");
  assert_eq!(scope, ());
}

/// `C: ?Sized`, so a manager reached as a trait object is still borrowable — the bound exists for
/// backends whose manager is held behind `dyn`.
#[test]
fn an_unsized_connection_is_borrowable() {
  let manager: &dyn core::fmt::Debug = &"a client";
  let ctx = Connected::new(manager, ());

  assert_eq!(format!("{:?}", ctx.connection()), "\"a client\"");
}

/// Constructible in a `const`, which is what keeps the bundle free at an op head: it is two fields
/// and no work, and a `const fn` evaluated in a `const` cannot allocate.
#[test]
fn a_bundle_is_const_constructible() {
  const MANAGER: &str = "root";
  const CTX: Connected<'static, str, ()> = Connected::new(MANAGER, ());

  assert_eq!(CTX.connection(), "root");
}