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
22mod ops_compare;
23mod ops_macros;
24
25/// rendering a value as SQL, used by `${arg}` interpolation
26pub mod into_sql;
27pub use into_sql::IntoSql;
28/// parsers and code generators of the `py_sql` and `html_sql` languages
29pub mod codegen;
30/// error type of the code generator
31pub mod error;
32/// `bool` helpers available inside a template expression
33pub mod from_bool;
34/// operators (`+`, `==`, `.sql()`, ...) usable inside a template
35pub mod ops;
36/// `+` operator
37pub mod ops_add;
38/// `&` (bit and) operator
39pub mod ops_bit_and;
40/// `|` (bit or) operator
41pub mod ops_bit_or;
42/// comparison operators (`>`, `<`, `>=`, `<=`)
43pub mod ops_cmp;
44/// `/` operator
45pub mod ops_div;
46/// `==` operator
47pub mod ops_eq;
48/// `*` operator
49pub mod ops_mul;
50/// unary `-` operator
51pub mod ops_neg;
52/// `!` operator
53pub mod ops_not;
54/// `%` operator
55pub mod ops_rem;
56/// `<<` operator
57pub mod ops_shl;
58/// `>>` operator
59pub mod ops_shr;
60/// string helpers (`.sql()`, `.csv()`, ...)
61pub mod ops_string;
62/// `-` operator
63pub mod ops_sub;
64/// `^` operator
65pub mod ops_xor;
66pub use codegen::{rb_html, rb_py};