Expand description
§Alcro
Alcro is a library to create desktop apps using rust and modern web technologies.
It uses the existing chrome installation for the UI. The API is async and runs on
the tokio runtime.
§Example
#![windows_subsystem = "windows"]
use alcro::{UIBuilder, Content};
use serde_json::to_value;
#[tokio::main]
async fn main() {
let ui = UIBuilder::new().content(Content::Html("<html><body>Close Me!</body></html>")).run().await.expect("Unable to launch");
assert_eq!(ui.eval("document.body.innerText").await.unwrap(), "Close Me!");
//Expose rust function to js
ui.bind("product", |args| async move {
let mut product = 1;
for arg in args {
match arg.as_i64() {
Some(i) => product *= i,
None => return Err(to_value("Not number").unwrap()),
}
}
Ok(to_value(product).unwrap())
}).await.expect("Unable to bind function");
assert_eq!(ui.eval("(async () => await product(1,2,3))();").await.unwrap(), 6);
assert!(ui.eval("(async () => await product(1,2,'hi'))();").await.is_err());
ui.wait_finish().await;
}To change the path of the browser launched set the ALCRO_BROWSER_PATH environment variable. Only Chromium based browsers work.
Re-exports§
pub use locate::tinyfiledialogs as dialog;
Structs§
- Bounds
- A struct that stores the size, position and window state of the browser window.
- JSError
- An error from chrome in JSON format
- UI
- A browser window.
- UIBuilder
- Builder for constructing a UI instance.
Enums§
- Content
- Specifies the type of content shown by the browser
- LogOutput
- Where to log the browser’s console messages and uncaught exceptions.
- UILaunch
Error - Error in launching a UI window
- Window
State - The state of the window