1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#![doc(
    html_logo_url = "https://rillrate.com/images/logo/rr-stack.svg",
    html_favicon_url = "https://rillrate.com/images/favicon.png",
    html_root_url = "https://docs.rillrate.com/"
)]
#![warn(missing_docs)]

//! 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](../way_basis/index.html) - the core components that commonly used by other packs._
//! - [AutoLayout](../way_auto_layout/index.html) - layouts with automatic arranging of elements.
//! - [Control](../way_control/index.html) - basic controls: button, selector, and so on.
//! - [Visual](../way_visual/index.html) - 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`](install::install) method to start the supervisor with the engine:
//!
//! ```rust
//! 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.interrupt();
//!    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:
//!
//! ```rust
//! 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.interrupt();
//!    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][localhost]
//! when the app is started.
//!
//! [localhost]: http://localhost:6361/
//!
//! ### 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:
//!
//! ```sh
//! 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:
//!
//! ```rust
//! 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`:
//!
//! ```rust
//! 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.
//!

mod actors;
pub mod extras;
mod install;

pub use install::install;

pub use actors::supervisor::{Way, WayLink};

// TODO: How to improve that imports?
pub use rill_engine as engine;
pub use rill_engine::tracer::callback::{
    CallbackAction, CallbackBuilder, CallbackEvent, CallbackGuard, CallbackReceiver,
};

pub use rill_engine::TracerOpts;