Crate rillrate[][src]

Expand description

This is the main package that easily allows you to build user interfaces.

The idea of this package to embed an asynchronous web server that provides a built-in web dashboard.

The crate contains the main actor. To add UI components use packs.

Packs

The list of packs with UI components and layouts:

  • Basis Pack - the core components that commonly used by other packs.
  • AutoLayout - layouts with automatic arranging of elements.
  • Control - basic controls: button, selector, and so on.
  • Visual - visual components: text, tables, and more like that.

Usage

Standard frontend

The crate already embeds a frontend automatically if the default feature app is activated.

Use install method to start the supervisor with the engine:

use anyhow::Error;

#[tokio::main]
async fn main() -> Result<(), Error> {
   let (mut system, supervisor) = rillrate::install()?;

   // Spawn your actor here
   // let app = App::new(supervisor);
   // system.spawn(app)?;

   system.join().await;
   Ok(())
}

It used default frontend all rillrate-app with a minimal set of necessary packs.

Customized frontend

The main function

In order to add UI to your application, you need to run a Way that will start the server and will serve incoming connections and ensure reliable data transfer.

Use the following code to create and start the Way instance:

use anyhow::Error;
use meio::system::{System, SystemLink};
use rillrate::{Way, TracerOpts};
use way_auto_layout::*;

#[tokio::main]
async fn main() -> Result<(), Error> {
   let mut system = System::new().start();
   system.set_signal_handler()?;

   let mut supervisor = system.spawn(Way::new())?;
   // Add assets
   // supervisor.install_app(APP_ASSETS)?;
   let column_layout = ColumnLayout::new("local.layout");
   supervisor.set_root(&column_layout.flow_bind)?;

   // Spawn your tasks here.

   system.join().await;

   Ok(())
}

The code starts the supervisor actor in the System, which in turn starts the server. It opens 6361 port with the web UI. Try to connect to localhost:6361 when the app is started.

Add assets

By default the actor downloads and uses prebuilt assets. But you can also build your own customized app.

For example, facade crate already contains the frontend app that includes all necessary packs. To use it directly you have to build facade using trunk tool:

trunk build --release --public-url "/app/"

Or use cargo make, because it already contains Makefile.toml with necessary task to build the frontend using the trunk tool.

When the frontend part is ready pack it using the rate_melt crate. Add to build.rs file of your project:

fn main() -> Result<(), Box<dyn std::error::Error>> {
   rate_melt::melt("../path/to/stack/facade/dist", "RR_APP")?;
   Ok(())
}

Than you can embed packed assets to the app. Add to the main.rs:

const APP_ASSETS: rate_melt::PackedAssets = rate_melt::embed!("RR_APP");

Env vars

The Way supports environment variables to override parameters in the app. The following env vars available:

  • RR_ADDR - the address and port to bind the server to.

Re-exports

pub use rill_engine as engine;

Modules

Utilities.

Structs

An action received by an actor.

Generates and registers a callback.

An event sent to a callback.

A guard to keep the callback alive.

An async receiver for events.

Options to set parameters to a Tracer.

The main actor. Spawn it to launch the web UI.

The link to control the Way actor.

Functions

Install the RillRate.