edgedb_codegen/
lib.rs

1#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/cargo.md"))]
2//! ## Features
3#![doc = document_features::document_features!()]
4#![cfg_attr(docsrs, feature(doc_cfg))]
5
6/// Generates a query module from a query string.
7///
8/// ```rust
9/// use edgedb_codegen::edgedb_query;
10///
11/// edgedb_query!(get_users, "select User {**}");
12/// ```
13///
14/// This macro can be called with one argument if in the root of your crate you
15/// host a folder named `queries`.
16///
17/// ```rust
18/// use edgedb_codegen::edgedb_query;
19///
20/// edgedb_query!(insert_user);
21/// ```
22///
23/// The above code will find the file `<CRATE_ROOT>/queries/insert_user.edgeql`
24/// and run the query from there.
25#[macro_export]
26macro_rules! edgedb_query {
27	($module:ident, $query:literal) => {
28		$crate::exports::edgedb_codegen_macros::edgedb_query_raw!($module, query: $query);
29	};
30	($module: ident) => {
31		$crate::exports::edgedb_codegen_macros::edgedb_query_raw!($module);
32	};
33}
34
35/// Generates a query module from a query string relative to the root of the
36/// crate this is defined in. This is useful for queries that are not placed in
37/// the `queries` folder at the root of the crate.
38///
39/// ```rust
40/// use edgedb_codegen::edgedb_query_file;
41///
42/// edgedb_query_file!(insert_user, "queries/insert_user.edgeql");
43/// ```
44///
45/// The above code can actually be replaced with the
46/// `edgedb_query!(insert_user)` macro since the file is placed in the `queries`
47/// folder.
48#[macro_export]
49macro_rules! edgedb_query_file {
50	($module:ident, $path:literal) => {
51		$crate::exports::edgedb_codegen_macros::edgedb_query_raw!($module, file: $path);
52	};
53}
54
55pub mod exports {
56	#[cfg(feature = "with_bigdecimal")]
57	#[cfg_attr(docsrs, doc(cfg(feature = "with_bigdecimal")))]
58	pub use bigdecimal;
59	pub use bytes;
60	#[cfg(feature = "with_chrono")]
61	#[cfg_attr(docsrs, doc(cfg(feature = "with_chrono")))]
62	pub use chrono;
63	pub use edgedb_codegen_macros;
64	#[cfg(feature = "query")]
65	#[cfg_attr(docsrs, doc(cfg(feature = "query")))]
66	pub use edgedb_derive;
67	pub use edgedb_errors;
68	pub use edgedb_protocol;
69	#[cfg(feature = "query")]
70	#[cfg_attr(docsrs, doc(cfg(feature = "query")))]
71	pub use edgedb_tokio;
72	#[cfg(any(feature = "with_bigdecimal", feature = "with_bigint"))]
73	#[cfg_attr(
74		docsrs,
75		doc(cfg(any(feature = "with_bigdecimal", feature = "with_bigint")))
76	)]
77	pub use num_bigint;
78	#[cfg(any(feature = "with_bigdecimal", feature = "with_bigint"))]
79	#[cfg_attr(
80		docsrs,
81		doc(cfg(any(feature = "with_bigdecimal", feature = "with_bigint")))
82	)]
83	pub use num_traits;
84	#[cfg(feature = "serde")]
85	#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
86	pub use serde;
87	#[cfg(feature = "builder")]
88	#[cfg_attr(docsrs, doc(cfg(feature = "builder")))]
89	pub use typed_builder;
90	pub use uuid;
91}