brisk_it/
lib.rs

1//! brisk-it is a macro-based system for transforming a declarative representation into
2//! imperative Rust code. Its main application is currently for developing [egui](https://www.egui.rs/)
3//! user interface.
4
5#![warn(missing_docs)]
6#![deny(warnings)]
7
8extern crate proc_macro;
9
10pub mod component;
11pub mod errors;
12pub mod generator;
13mod utils_impl;
14
15pub use utils_impl::Either;
16pub use utils_impl::Required;
17
18/// Utility module.
19pub mod utils {
20    pub use crate::utils_impl::blockify;
21    pub use crate::utils_impl::component_or_expression;
22}
23
24/// Result type, which return a token stream with the error
25pub type Result<T> = std::result::Result<T, proc_macro2::TokenStream>;
26
27use proc_macro::TokenStream;
28use syn::parse_macro_input;
29
30/// This is the core entry point of the brisk library. It should be used in a macro-proc to
31/// trigger the transformation between the declarative representation and generate the Rust code.
32pub fn brisk_it(
33    input: proc_macro::TokenStream,
34    generator_manager: &generator::Manager,
35) -> TokenStream {
36    let input = parse_macro_input!(input as component::ComponentInput);
37    let output = generator_manager.generate(input).either();
38    // println!("----\n\n\n\n{}\n\n\n\n----", output.to_string());
39    output.into()
40}