rbatis_codegen/lib.rs
1//! Compile time dynamic SQL generator.
2//!
3//! This is the compiler behind `#[py_sql]`, `#[html_sql]` and `#[sql]` (provided by
4//! the `rbatis-macro-driver` crate and re-exported as
5//! [`rbatis::rbatis_codegen`](https://docs.rs/rbatis/latest/rbatis/)). A dynamic SQL
6//! template is parsed here and turned into plain Rust source code, which is then
7//! compiled by the `rustc` invocation that is already running. That is why a query
8//! written in `py_sql`/`html_sql` runs as fast as hand written SQL: nothing is
9//! interpreted at runtime.
10//!
11//! * [`codegen::func`] holds the code generation functions
12//! * [`codegen::parser_pysql`] and [`codegen::parser_html`] parse the two languages
13//! * [`codegen::syntax_tree_pysql`] and [`codegen::syntax_tree_html`] are the
14//! abstract syntax trees they produce
15//! * [`ops`] contains the operators that are available inside a template
16//! (`+`, `==`, `.sql()`, `.csv()`, ...)
17//! * [`IntoSql`] renders a value as SQL, used by `${arg}` interpolation
18//!
19//! Most users never depend on this crate directly; it is documented because it is
20//! re-exported from rbatis.
21
22/// rendering a value as SQL, used by `${arg}` interpolation
23pub mod into_sql;
24pub use into_sql::IntoSql;
25/// parsers and code generators of the `py_sql` and `html_sql` languages
26pub mod codegen;
27/// error type of the code generator
28pub mod error;
29/// `bool` helpers available inside a template expression
30pub mod from_bool;
31/// operators (`+`, `==`, `.sql()`, ...) usable inside a template
32pub mod ops;
33/// `+` operator
34pub mod ops_add;
35/// `&` (bit and) operator
36pub mod ops_bit_and;
37/// `|` (bit or) operator
38pub mod ops_bit_or;
39/// comparison operators (`>`, `<`, `>=`, `<=`)
40pub mod ops_cmp;
41/// `/` operator
42pub mod ops_div;
43/// `==` operator
44pub mod ops_eq;
45/// `*` operator
46pub mod ops_mul;
47/// unary `-` operator
48pub mod ops_neg;
49/// `!` operator
50pub mod ops_not;
51/// `%` operator
52pub mod ops_rem;
53/// `<<` operator
54pub mod ops_shl;
55/// `>>` operator
56pub mod ops_shr;
57/// string helpers (`.sql()`, `.csv()`, ...)
58pub mod ops_string;
59/// `-` operator
60pub mod ops_sub;
61/// `^` operator
62pub mod ops_xor;
63pub use codegen::{rb_html, rb_py};