Skip to main content

rete_core/
lib.rs

1//! Core on-disk types for the Rete graph file format.
2//!
3//! See `docs/SPEC.md` for the full design. This crate owns the byte-level
4//! layout (header, directory, blocks) and is deliberately free of any I/O or
5//! query logic so it compiles cleanly to both native and `wasm32`.
6
7#![deny(rustdoc::broken_intra_doc_links)]
8#![warn(missing_docs)]
9
10/// The engine version, as published on crates.io.
11///
12/// Language bindings re-export this so a caller can always tell which engine is
13/// embedded in their wheel, npm package, or bundle. That is the question behind
14/// "does my install support feature X?", and it is not answerable from the
15/// binding's own version, which tracks the binding. Client versions match this
16/// crate's `MAJOR.MINOR` (see `scripts/sync_versions.py`) while their patch
17/// component moves independently for binding-only fixes.
18pub const VERSION: &str = env!("CARGO_PKG_VERSION");
19
20#[doc(hidden)]
21pub mod bgp;
22#[doc(hidden)]
23pub mod block_cache;
24#[doc(hidden)]
25pub mod dict;
26#[doc(hidden)]
27pub mod dictionary;
28#[doc(hidden)]
29pub mod extbuild;
30#[doc(hidden)]
31pub mod file;
32#[doc(hidden)]
33pub mod geo;
34pub mod geo3;
35#[doc(hidden)]
36pub mod header;
37#[doc(hidden)]
38pub mod index;
39
40pub mod ingest;
41#[doc(hidden)]
42pub mod meta;
43#[cfg(feature = "parallel")]
44#[doc(hidden)]
45pub mod parallel;
46#[doc(hidden)]
47pub mod pyramid;
48#[doc(hidden)]
49pub mod reach;
50#[doc(hidden)]
51pub mod reader;
52#[doc(hidden)]
53pub mod reason;
54#[doc(hidden)]
55pub mod results;
56mod row;
57#[doc(hidden)]
58pub mod schema_pyramid;
59#[doc(hidden)]
60pub mod service;
61#[doc(hidden)]
62pub mod shacl;
63#[doc(hidden)]
64pub mod sparql;
65#[doc(hidden)]
66pub mod terms;
67#[doc(hidden)]
68pub mod text_index;
69#[doc(hidden)]
70pub mod tiling;
71#[doc(hidden)]
72pub mod triples;
73#[doc(hidden)]
74pub mod varint;
75
76/// Stable file-format, reader, and in-memory build API.
77pub mod format {
78    pub use crate::file::{
79        verify, ByteRange, FileError, LayoutSegment, Rete, TermTriple, TripleProvenance,
80        CODEC_NONE, CODEC_ZSTD, RDF_TYPE,
81    };
82    pub use crate::header::{
83        Header, HeaderError, Section, SectionKind, CURRENT_FORMAT_VERSION, HEADER_LEN, MAGIC,
84        MIN_STABLE_READ_VERSION,
85    };
86    pub use crate::ingest::{
87        assemble_dataset, assemble_dataset_with, assemble_dataset_with_opts,
88        assemble_dataset_with_opts_algo, parse, parse_quads, parse_rdfxml, parse_statements,
89        parse_turtle, BuildStats, IngestError, RawQuad, RawTriple,
90    };
91}
92
93/// Stable SPARQL, graph-pattern, federation, and result API.
94pub mod query {
95    pub use crate::bgp::{Binding, PatternTerm, TriplePattern};
96    pub use crate::file::TripleProvenance;
97    pub use crate::results::{push_json_string, results_envelope_json};
98    pub use crate::service::{
99        parse_sparql_json_results, sparql_json_ask, sparql_json_results, ServiceClient,
100    };
101    pub use crate::sparql::{
102        eval_query, eval_query_reasoned, eval_select_communities, eval_sparql,
103        eval_sparql_reasoned, query_predicates, routed_triple_pattern, summary_query_shape,
104        CommunityPartial, CommunitySelect, QueryOutput, RoutedTriplePattern, SparqlError,
105        SummaryQueryShape,
106    };
107}
108
109/// Stable byte-range and lazy-open API for local or remote `.rete` files.
110pub mod range {
111    pub use crate::block_cache::{auto_block, BlockCacheReader, DEFAULT_BLOCK, DEFAULT_CACHE_CAP};
112    pub use crate::file::{
113        read_metadata_ranged, read_schema_coherence_ranged, read_schema_summary_ranged, ByteRange,
114        LayoutSegment, SummaryView,
115    };
116    pub use crate::reader::{CountingReader, RangeReader, SliceReader};
117}
118
119/// Stable integrity and SHACL validation API.
120pub mod validation {
121    pub use crate::file::verify;
122    pub use crate::shacl::{
123        validate_shacl, DataGraph, GraphView, ReteGraph, Severity, ShaclError, ShaclShapes,
124        ValidationReport, ValidationResult,
125    };
126}
127
128/// Stable RDFS/OWL reasoning and schema-coherence API.
129pub mod reasoning {
130    pub use crate::file::{
131        read_schema_coherence_ranged, schema_coherence, schema_summary, TermTriple,
132    };
133    pub use crate::reason::{reason, Inconsistency, Reasoning, REASON_RULESET};
134    pub use crate::sparql::{eval_query_reasoned, eval_sparql_reasoned};
135}
136
137#[doc(hidden)]
138pub use bgp::{eval_bgp, Binding, PatternTerm, TriplePattern};
139#[doc(hidden)]
140pub use block_cache::{auto_block, BlockCacheReader, DEFAULT_BLOCK, DEFAULT_CACHE_CAP};
141#[doc(hidden)]
142pub use dict::{DictSection, DictSectionBuilder};
143#[doc(hidden)]
144pub use dictionary::{Dictionary, DictionaryBuilder};
145#[doc(hidden)]
146pub use file::{
147    build_pyramid_meta, build_pyramid_meta_algo, build_pyramid_meta_with, read_metadata_ranged,
148    read_schema_coherence_ranged, read_schema_summary_ranged, schema_classes, schema_coherence,
149    schema_summary, verify, write_dataset, write_dataset_with_metadata, write_file, ByteRange,
150    LayoutSegment, Rete, SummaryView, TermTriple, TripleProvenance, CODEC_NONE, CODEC_ZSTD,
151    DEFAULT_TILE_BUDGET, RDF_TYPE,
152};
153#[doc(hidden)]
154pub use header::{
155    Header, HeaderError, Section, SectionKind, CURRENT_FORMAT_VERSION, HEADER_LEN, MAGIC,
156    MIN_STABLE_READ_VERSION,
157};
158#[doc(hidden)]
159pub use index::{GraphIndex, GraphIndexBuilder, IndexPermutation, Pattern};
160#[doc(hidden)]
161pub use meta::{
162    CharSet, ClassNode, ClassRelation, CommunityDescriptor, LabelEntry, LevelLinks, LevelRollup,
163    PredStat, PyramidMeta,
164};
165#[doc(hidden)]
166pub use pyramid::{
167    build_dendrogram, louvain_one_level, project_graph, Dendrogram, Graph, Partition, PyramidAlgo,
168};
169#[doc(hidden)]
170pub use reach::{batch_reach_serial, build_adjacency, reach_one};
171#[doc(hidden)]
172pub use reader::{CountingReader, RangeReader, SliceReader};
173#[doc(hidden)]
174pub use reason::{reason, Inconsistency, Reasoning, REASON_RULESET};
175#[doc(hidden)]
176pub use results::{push_json_string, results_envelope_json};
177#[doc(hidden)]
178pub use schema_pyramid::build_schema_pyramid;
179#[doc(hidden)]
180pub use service::{parse_sparql_json_results, sparql_json_ask, sparql_json_results, ServiceClient};
181#[doc(hidden)]
182pub use shacl::{
183    validate_shacl, DataGraph, GraphView, ReteGraph, Severity, ShaclError, ShaclShapes,
184    ValidationReport, ValidationResult,
185};
186#[doc(hidden)]
187pub use sparql::{
188    eval_query, eval_query_reasoned, eval_select_communities, eval_sparql, eval_sparql_reasoned,
189    parse_select, query_predicates, routed_triple_pattern, summary_query_shape, Agg,
190    CommunityPartial, CommunitySelect, FExpr, GraphTarget, GroupSpec, Op, PathAst, Plan,
191    QueryOutput, Rep, RoutedTriplePattern, Select, SparqlError, SummaryQueryShape,
192};
193#[doc(hidden)]
194pub use terms::{NodeId, ObjectId, PredicateId, SubjectId, TermToken};
195#[doc(hidden)]
196pub use text_index::{tokenize, TextIndex, TextIndexBuilder};
197#[doc(hidden)]
198pub use tiling::{choose_round_for_budget, summarize, tile_by_community, SuperEdge, Tile};
199#[doc(hidden)]
200pub use triples::{GroupDirectory, Triple, TripleBlock, TripleBlockBuilder, ZoneMap};