crossmap/lib.rs
1//! A bidirectional crosswalk codec.
2//!
3//! One crosswalk document describes how to map between a dataset's native JSON shape and a shared target shape, and
4//! that one document derives both directions: every two-way operation knows its own inverse, so [`decode`] undoes
5//! [`encode`] over the paths the crosswalk maps. What cannot be undone is declared as one-way rules. Rules are gated
6//! with trilean predicate trees.
7//!
8//! Documents are [`Value`]s, an ordered JSON value whose numbers are doubles read and written as JavaScript reads and
9//! writes them, so a document means here what it means to JavaScript's `JSON.parse`. The crate does no input or
10//! output and compiles to `wasm32-unknown-unknown`.
11
12#![forbid(unsafe_code)]
13
14mod crosswalk;
15mod error;
16mod executor;
17mod js;
18mod ops;
19mod output;
20mod path;
21mod roundtrip;
22pub mod schema;
23mod validate;
24mod when;
25
26pub use crosswalk::{
27 AggregateFunction, Crosswalk, Direction, FormatKind, OneWayRule, RuleSides, SinglePath,
28 TwoWayRule, parse_crosswalk, rule_sides,
29};
30pub use error::{CrossmapError, CrosswalkIssue, SyntaxIssue};
31pub use executor::{Compiled, compile_crosswalk, decode, encode};
32pub use js::{canonical_json, js_ordered, stringify, stringify_pretty};
33pub use json_shape::Value;
34pub use path::{
35 EmptySite, PathMatch, PathStep, Reading, TrailStep, format_path, format_trail, is_path,
36 parse_path, read_path, wildcard_count,
37};
38pub use roundtrip::assert_round_trip;
39pub use validate::validate_crosswalk;
40pub use when::{Gate, When, WhenElement};
41
42// The Rust examples of the repository's docs/usage.md, compiled and run as this crate's doctests, so the usage guide
43// cannot show code that does not build or results the codec does not give. Only under rustdoc's doctest pass, which is the one build
44// that reads the file: a crate built from its published package never evaluates the path.
45#[cfg(doctest)]
46#[doc = include_str!("../../../../docs/usage.md")]
47struct UsageExamples;