Crate alcro[][src]

Alcro

Alcro is a library to create desktop apps using rust and modern web technologies. It uses the existing chrome installation for the UI.

Example

#![windows_subsystem = "windows"]
use alcro::{UIBuilder, Content};
use serde_json::to_value;

let ui = UIBuilder::new().content(Content::Html("<html><body>Close Me!</body></html>")).run().expect("Unable to launch");
assert_eq!(ui.eval("document.body.innerText").unwrap(), "Close Me!");

//Expose rust function to js
ui.bind("product",|args| {
    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())
}).expect("Unable to bind function");

assert_eq!(ui.eval("(async () => await product(1,2,3))();").unwrap(), 6);
assert!(ui.eval("(async () => await product(1,2,'hi'))();").is_err());
ui.wait_finish();

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

The browser window

UIBuilder

Builder for constructing a UI instance.

Enums

Content

Specifies the type of content shown by the browser

UILaunchError

Error in launching a UI window

WindowState

The state of the window

Type Definitions

JSObject

A JS object. It is an alias for serde_json::Value. See it’s documentation for how to use it.

JSResult

The result of a JS function.