Skip to main content

Crate datafox

Crate datafox 

Source
Expand description

Datafox is a standalone Datalog parser and streaming query engine for facts.

The crate is intentionally small: callers provide facts through Storage, parse read-only queries with parse_query or parse_queries, and evaluate them with a DatafoxClient configured for the runtime profile you need.

use datafox::{DatafoxClient, DatafoxConfig, InMemoryStorage, Value, parse_query};

let storage = InMemoryStorage::from_facts([(
    "edge".to_string(),
    vec![
        vec![Value::integer(1), Value::integer(2)],
        vec![Value::integer(2), Value::integer(3)],
    ],
)]);
let query = parse_query("edge(From, 2)")?;
let datafox = DatafoxClient::new(DatafoxConfig::new(&storage))?;
let results = datafox.eval(&query)?.collect::<Vec<_>>();

assert_eq!(results.len(), 1);
assert_eq!(results[0].lookup("From"), Some(&Value::integer(1)));

Public API:

Re-exports§

pub use error::Error;
pub use error::Result;

Modules§

error

Macros§

atom
lit
subst
var

Structs§

Atom
A predicate applied to a list of terms.
BinaryOperator
BinaryRelation
DatafoxClient
DatafoxConfig
DatafoxEnvironment
DatafoxEnvironmentBuilder
Diagnostic
One contextual parser or analyzer diagnostic.
Evaluation
Iterator over substitutions produced by an evaluator run.
FactEstimate
FactRequest
FactRequestHints
InMemoryPreparedQueryStorage
InMemoryStorage
Planner
Prelude
PreparedQuery
PreparedQueryKey
Span
One source span in an input query string.
Substitution
A deterministic mapping from variable names to concrete values.
Unifier
Stateless helpers for unification and atom-to-tuple matching.
Universe
A read-only query snapshot over a storage backend.

Enums§

AtomRole
Clause
One clause in a query body.
EvaluationStrategy
FactRequestMode
FactScan
OperatorOutcome
PatternValue
Projection
Query
A read-only Datalog query.
RelationOutcome
SnapshotSelector
Term
One Datalog term.
Value
Concrete constant values that can appear in Datalog facts and queries.

Constants§

PREPARED_QUERY_FORMAT_VERSION

Traits§

FactStore
PreparedQueryStorage
Storage
Snapshot-oriented read-only storage interface for Datalog queries.

Functions§

format_queries
format_query
matches_pattern
parse_queries
parse_query

Type Aliases§

FactTuple
Plan
PlanningCache
TupleStream