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
//! This library, [bui-backend](https://github.com/astraw/bui-backend), enables
//! an application to serve a [Browser User Interface
//! (BUI)](https://en.wikipedia.org/wiki/Browser_user_interface). The browser
//! becomes your GUI. The API is based on futures and reactively pushes state to
//! the browser. Assets can be served from the filesystem or bundled in the
//! executable. The server provides an "escape hatch" to allow server-client
//! communication outside of bui-backend. [The demo][bui-demo] includes a plain
//! Javascript frontend and an Elm frontend.
//!
//! The operating principle is that the server runs an HTTP server (based on
//! [hyper](https://hyper.rs)) to which the browser connects. The initial page
//! tells the browser to open a connection to a [Server Sent
//! Events](https://html.spec.whatwg.org/multipage/server-sent-events.html)
//! endpoint and the server can subsequently push updates to the browser.
//! Additionally, the server listens for POST callbacks on another endpoint. All
//! data is encoded as JSON.
//!
//! #### Features
//!
//!  - Uses [raii-change-tracker](https://crates.io/crates/raii-change-tracker)
//!    to ensure that server state changes are reactively sent to all connected
//!    frontends.
//!  - To keep things simple, server state is shared with all connected clients.
//!  - Session keys (per browser) and connection keys (per tab) are maintained
//!    and allow taking control of communication using pre-established event
//!    stream. (This is an "escape hatch" to break out of the bui-backend
//!    abstractions as required by some use cases.)
//!  - Demo frontends written in Javascript and Elm. (Use [`bui-demo`][bui-demo]
//!    with `frontend_js` or `frontend_elm` feature.)
//!  - Written in async style using
//!    [futures-rs](https://github.com/alexcrichton/futures-rs).
//!  - Uses [Serde JSON](https://crates.io/crates/serde_json).
//!  - Compile-time choice between bundling served files into executable (with
//!    `bundle_files` feature) or reading files from disk (`serve_files`).
//!
//! #### Security warning
//!
//! Due to its nature, the program listens and responds to client connections
//! from the network. If you expose your program to untrusted network
//! connections, ensure that code within any callback handlers you write is safe
//! when handling malicious input.
//!
//! [bui-demo]: https://github.com/astraw/bui-backend/tree/master/bui-demo
#![deny(missing_docs)]

#[macro_use]
extern crate serde_derive;

#[macro_use]
extern crate log;
#[macro_use]
extern crate error_chain;
extern crate raii_change_tracker;
#[cfg(feature = "bundle_files")]
extern crate includedir;
extern crate serde;
extern crate serde_json;
extern crate futures;
extern crate hyper;
extern crate jsonwebtoken;
extern crate uuid;

pub mod errors;
pub mod lowlevel;
pub mod highlevel;