Skip to main content

Crate haystack_core

Crate haystack_core 

Source
Expand description

§Haystack Core

Rust implementation of the Project Haystack data model, codecs, filter engine, entity graph, ontology system, and SCRAM SHA-256 authentication.

§Crate Organization

ModuleDescription
kindsCentral value type (Kind) with 15 scalar types (Marker, Number, Str, Ref, etc.)
dataCollection types: HDict (tag map), HGrid (table), HCol, HList
codecsWire format codecs: Zinc, Trio, JSON, Haystack JSON v3, CSV, and RDF (Turtle/JSON-LD)
filterHaystack filter expression parser and evaluator (site and area > 1000)
graphIn-memory entity graph with bitmap tag indexes, B-tree value indexes, ref adjacency, CSR, and change tracking
ontologyHaystack 4 def/lib/namespace system with taxonomy, validation, and Xeto support
authSCRAM SHA-256 authentication per the Haystack auth specification
xetoXeto schema language parser and structural type fitting

§Quick Start

use haystack_core::data::{HDict, HGrid};
use haystack_core::kinds::{Kind, Number, HRef};
use haystack_core::graph::EntityGraph;
use haystack_core::codecs::codec_for;

// Build an entity
let mut site = HDict::new();
site.set("id", Kind::Ref(HRef::from_val("site-1")));
site.set("dis", Kind::Str("Main Campus".into()));
site.set("site", Kind::Marker);
site.set("area", Kind::Number(Number::unitless(50000.0)));

// Add to graph and query
let mut graph = EntityGraph::new();
graph.add(site).unwrap();
let results = graph.read_all("site and area > 1000", 0).unwrap();
assert_eq!(results.len(), 1);

// Encode to Zinc wire format
let zinc = codec_for("text/zinc").unwrap();
let grid = graph.to_grid("").unwrap();
let encoded = zinc.encode_grid(&grid).unwrap();

Modules§

auth
SCRAM SHA-256 authentication primitives for the Haystack auth protocol.
codecs
Haystack wire format codecs for serialization and deserialization.
data
Haystack data collection types.
expr
Expression evaluator for arithmetic/logic expressions over entity tags.
filter
Haystack filter expression parser and evaluator.
graph
In-memory entity graph with indexed querying, change tracking, and thread-safe access.
kinds
Haystack type system — the Kind enum and its 15 scalar types.
ontology
Haystack 4 ontology layer — defs, taxonomy, conjuncts, and validation.
xeto