waveless_commons/
runtime.rs1use crate::*;
5
6use tokio::runtime::Builder;
7
8pub fn handle_main<T>(main_fn: T) -> Result<()>
11where
12 T: AsyncFn() -> Result<CompactString>,
13{
14 color_eyre::install()?;
15
16 let runtime = Builder::new_multi_thread()
17 .enable_all()
18 .thread_stack_size(128 * 1024 * 1024)
19 .build()
20 .unwrap();
21
22 runtime.block_on(async {
23 match main_fn().await {
24 Ok(res) => {
25 if !res.is_empty() {
26 element! {
27 View(
28 padding_left: 1,
29 padding_right: 1,
30 border_style: BorderStyle::Round,
31 border_color: iocraft::Color::Green,
32 ) {
33 MixedText(align: TextAlign::Left, contents: vec![
34 MixedTextContent::new("✅ "),
35 MixedTextContent::new("SUCCESS: ").color(iocraft::Color::Green).weight(Weight::Bold),
36 MixedTextContent::new(res).color(iocraft::Color::White),
37 ])
38 }
39 }
40 .print();
41 }
42 }
43 Err(err) => return Err(err)
44 }
45 Ok(())
46 })
47}