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
7extern crate proc_macro;
8
9pub mod component;
10pub mod errors;
11pub mod generator;
12mod utils_impl;
13
14pub use utils_impl::Either;
15pub use utils_impl::Required;
16
17/// Utility module.
18pub mod utils {
19    pub use crate::utils_impl::blockify;
20    pub use crate::utils_impl::component_or_expression;
21}
22
23/// Result type, which return a token stream with the error
24pub type Result<T> = std::result::Result<T, proc_macro2::TokenStream>;
25
26use proc_macro::TokenStream;
27use syn::parse_macro_input;
28
29/// This is the core entry point of the brisk library. It should be used in a macro-proc to
30/// trigger the transformation between the declarative representation and generate the Rust code.
31pub fn brisk_it(
32    input: proc_macro::TokenStream,
33    generator_manager: &generator::Manager,
34) -> TokenStream {
35    let input = parse_macro_input!(input as component::ComponentInput);
36    let output = generator_manager.generate(input).either();
37    // println!("----\n\n\n\n{}\n\n\n\n----", output.to_string());
38    output.into()
39}