heim_derive/
lib.rs

1//! Proc-macros for `heim` crates.
2//!
3//! Do not use directly.
4
5#![doc(html_root_url = "https://docs.rs/heim-derive/0.0.10")]
6#![recursion_limit = "128"]
7#![deny(
8    unused,
9    unused_imports,
10    unused_features,
11    bare_trait_objects,
12    future_incompatible,
13    missing_debug_implementations,
14    missing_docs,
15    nonstandard_style,
16    dead_code,
17    deprecated
18)]
19#![warn(
20    trivial_casts,
21    trivial_numeric_casts,
22    unused_extern_crates,
23    unused_import_braces,
24    unused_results
25)]
26
27#[allow(unused_extern_crates)]
28extern crate proc_macro;
29
30use proc_macro::TokenStream;
31
32mod ci;
33mod dev;
34
35/// Used for `#[heim_derive::test]`-annotated functions
36///
37/// Will not run the annotated function if it is called in the CI environment.
38///
39/// It is important to put it **before** the `#[heim_derive::test]` attribute, like that:
40///
41/// ```text
42/// #[heim_derive::skip_ci]
43/// #[heim_derive::test]
44/// async fn test_foo() {}
45/// ```
46///
47/// Supported CI:
48///  * Azure Pipelines
49#[proc_macro_attribute]
50pub fn skip_ci(attr: TokenStream, item: TokenStream) -> TokenStream {
51    self::ci::skip_ci(attr, item)
52}
53
54/// Defines the async main function.
55///
56/// Same thing what `runtime::main` does, but without checks and with `futures::executor` instead.
57///
58/// It is used for `heim` examples only.
59#[cfg(not(test))]
60#[proc_macro_attribute]
61pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream {
62    self::dev::main(attr, item)
63}
64
65/// Defines the async test function.
66///
67/// It is used for `heim` test only. See `heim_derive::main` for additional details.
68#[proc_macro_attribute]
69pub fn test(attr: TokenStream, item: TokenStream) -> TokenStream {
70    self::dev::test(attr, item)
71}
72
73/// Defines the async benchmark function.
74///
75/// It is used for `heim` test only. See `heim_derive::main` for additional details.
76#[proc_macro_attribute]
77pub fn bench(attr: TokenStream, item: TokenStream) -> TokenStream {
78    self::dev::bench(attr, item)
79}