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::Ranked;

/// A score shape that is NOT `Copy`, which is what keeps the two gates honest: the borrow answers
/// for it and the by-value half is unreachable, exactly as [`Scored`](crate::Scored)'s pair is.
#[derive(Debug, Clone, PartialEq)]
struct Fused(Vec<f32>);

#[test]
fn the_three_halves_come_back_as_they_went_in() {
  let hit = Ranked::new(1.5_f32, 7, "media/12");

  assert_eq!(hit.score_ref(), &1.5);
  assert_eq!(hit.score(), 1.5);
  assert_eq!(hit.rank(), 7);
  assert_eq!(hit.node_ref(), &"media/12");
  assert_eq!(hit.node(), "media/12");
  assert_eq!(hit.clone().into_node(), "media/12");
  assert_eq!(hit.into_components(), (1.5, 7, "media/12"));
}

/// The borrow half answers for a score no `Copy` bound would admit — the gate is on the METHOD, so
/// the type stays available to it.
#[test]
fn a_score_that_cannot_be_copied_is_still_a_score() {
  let hit = Ranked::new(Fused(vec![0.25, 0.75]), 3, 12_u64);

  assert_eq!(hit.score_ref(), &Fused(vec![0.25, 0.75]));
  assert_eq!(hit.rank(), 3);
  assert_eq!(hit.node(), 12);
  assert_eq!(hit.into_components(), (Fused(vec![0.25, 0.75]), 3, 12_u64));
}

/// The tier-B carry: the node is replaced and BOTH numbers survive unchanged, which is the whole
/// reason the move is a method here rather than three field reads at the fill loop.
#[test]
fn the_node_swaps_and_the_numbers_ride_across() {
  let key = Ranked::new(0.5_f32, 9, "segment/3");

  let entity = key.map_node(String::from("the whole segment"));

  assert_eq!(entity.score(), 0.5);
  assert_eq!(entity.rank(), 9);
  assert_eq!(entity.node_ref(), "the whole segment");
}