Skip to main content

substrait_extensions/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Packaged Substrait extension files.
4//!
5//! This crate bundles the Substrait specification's extension YAML files, the
6//! text-based JSON schemas, and the function test cases, alongside Rust types
7//! generated from the schemas with [`typify`](https://docs.rs/typify).
8//!
9//! Versions of this crate correspond to Substrait
10//! [releases](https://github.com/substrait-io/substrait/releases).
11//!
12//! - [`text`] — types generated from the text schemas (e.g.
13//!   [`text::simple_extensions::SimpleExtensions`]), plus the raw schema
14//!   sources as consts (e.g. `text::SIMPLE_EXTENSIONS_SCHEMA`) for consumers
15//!   that validate raw YAML against the JSON schema.
16//! - [`extensions`] — the embedded extension YAML files, the
17//!   [`extensions::EXTENSIONS`] map (keyed by file stem to the parsed
18//!   extension), and the [`extensions::SIMPLE_EXTENSIONS`] slice (keyed by URN
19//!   to the raw YAML source).
20//! - [`testcases`] — the embedded function test case files.
21
22/// Types generated from the Substrait text-based JSON schemas, plus the raw
23/// schema sources as `&str` consts (e.g. `SIMPLE_EXTENSIONS_SCHEMA`).
24#[allow(
25    unused_variables,
26    clippy::clone_on_copy,
27    clippy::derivable_impls,
28    clippy::needless_borrow,
29    clippy::explicit_auto_deref,
30    clippy::to_string_trait_impl,
31    clippy::uninlined_format_args
32)]
33pub mod text {
34    include!(concat!(env!("OUT_DIR"), "/substrait_text.rs"));
35}
36
37/// The embedded Substrait core extension YAML files.
38///
39/// The contents of this module are auto-generated by `build.rs` and kept in
40/// sync with the packaged extension files.
41pub mod extensions {
42    include!(concat!(env!("OUT_DIR"), "/extensions.in"));
43}
44
45/// The embedded Substrait function test case files.
46pub mod testcases {
47    use include_dir::{include_dir, Dir};
48
49    /// The directory tree of `.test` function test case files.
50    pub static TESTCASES: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/testcases");
51}