Skip to main content

haystack_core/
lib.rs

1//! # Haystack Core
2//!
3//! Rust implementation of the [Project Haystack](https://project-haystack.org) data model,
4//! codecs, filter engine, entity graph, ontology system, and SCRAM SHA-256 authentication.
5//!
6//! ## Crate Organization
7//!
8//! | Module | Description |
9//! |--------|-------------|
10//! | [`kinds`] | Central value type ([`Kind`](kinds::Kind)) with 15 scalar types (Marker, Number, Str, Ref, etc.) |
11//! | [`data`] | Collection types: [`HDict`](data::HDict) (tag map), [`HGrid`](data::HGrid) (table), [`HCol`](data::HCol), [`HList`](data::HList) |
12//! | [`codecs`] | Wire format codecs: Zinc, Trio, JSON, Haystack JSON v3, CSV, and RDF (Turtle/JSON-LD) |
13//! | [`filter`] | Haystack filter expression parser and evaluator (`site and area > 1000`) |
14//! | [`graph`] | In-memory entity graph with bitmap tag indexes, B-tree value indexes, ref adjacency, CSR, and change tracking |
15//! | [`ontology`] | Haystack 4 def/lib/namespace system with taxonomy, validation, and Xeto support |
16//! | [`auth`] | SCRAM SHA-256 authentication per the Haystack auth specification |
17//! | [`xeto`] | Xeto schema language parser and structural type fitting |
18//!
19//! ## Quick Start
20//!
21//! ```rust
22//! use haystack_core::data::{HDict, HGrid};
23//! use haystack_core::kinds::{Kind, Number, HRef};
24//! use haystack_core::graph::EntityGraph;
25//! use haystack_core::codecs::codec_for;
26//!
27//! // Build an entity
28//! let mut site = HDict::new();
29//! site.set("id", Kind::Ref(HRef::from_val("site-1")));
30//! site.set("dis", Kind::Str("Main Campus".into()));
31//! site.set("site", Kind::Marker);
32//! site.set("area", Kind::Number(Number::unitless(50000.0)));
33//!
34//! // Add to graph and query
35//! let mut graph = EntityGraph::new();
36//! graph.add(site).unwrap();
37//! let results = graph.read_all("site and area > 1000", 0).unwrap();
38//! assert_eq!(results.len(), 1);
39//!
40//! // Encode to Zinc wire format
41//! let zinc = codec_for("text/zinc").unwrap();
42//! let grid = graph.to_grid("").unwrap();
43//! let encoded = zinc.encode_grid(&grid).unwrap();
44//! ```
45
46#[cfg(feature = "haystack-serde")]
47mod serde_impls;
48
49pub mod auth;
50pub mod codecs;
51pub mod data;
52pub mod expr;
53pub mod filter;
54pub mod graph;
55pub mod kinds;
56pub mod ontology;
57pub mod xeto;