Skip to main content

nifty_interp/
lib.rs

1//! Runs a checked Nifty program directly, driving the native UI through the runtime's
2//! engine. This is what `nf run` and `nf dev` use; `nf build` will compile the same program
3//! to machine code that drives the same engine instead.
4
5mod app;
6mod live;
7mod logic;
8mod lower;
9mod machine;
10mod value;
11
12use nifty_check::hir::Program;
13use nifty_runtime::{Backend, Ui};
14
15pub use app::{App, ErrorHandler};
16pub use live::LiveApp;
17pub use machine::RuntimeError;
18pub use value::Value;
19
20/// Shows the program's windows on `backend` and runs until the app quits. Errors during
21/// events go to `on_error`.
22///
23/// # Errors
24/// When setting up state or building the first UI fails.
25pub fn run<B: Backend>(
26    program: Program,
27    backend: B,
28    on_error: ErrorHandler,
29) -> Result<(), RuntimeError> {
30    let app = App::start(program, Ui::new(backend), on_error)?;
31    app.run();
32    Ok(())
33}
34
35#[cfg(test)]
36mod tests;