browser_window/
lib.rs

1//! _BrowserWindow_ is a Rust crate that allows you to utilize a browser engine
2//! to build graphical interfaces, similar to Electron.js.
3//! You create your user interface with HTML, CSS and JavaScript.
4//! Then, you can communicate information to JavaScript and back to Rust.
5//!
6//! Pick the underlying browser framework by setting feature `cef`, `webkitgtk`
7//! or `edge2`. For more info on which on you should choose and how to set them
8//! up, check [this guide](https://github.com/bamidev/browser-window/tree/master/docs/GETTING-STARTED.md).
9
10//! # Getting Started
11//! To start building apps with Browser Window, take a look at the
12//! [`application`](application/index.html) module, or this quick example:
13//! ```no_run
14//! use browser_window::{application::*, browser::*, prelude::*};
15//! 
16//! fn main() {
17//! 	let app = Application::initialize(&ApplicationSettings::default()).unwrap();
18//! 	let runtime = app.start();
19//! 	runtime.run_async(|app| async move {
20//! 		let mut bwb = BrowserWindowBuilder::new(Source::File("file:///my-file.html".into()));
21//! 		bwb.dev_tools(true);
22//! 		bwb.size(800, 600);
23//! 		bwb.title("Example");
24//! 		let bw = bwb.build_async(&app).await;
25//!         bw.on_message().register_async(|h, e| async move {
26//!             match e.cmd.as_str() {
27//!                 "command_one" => {
28//!                     h.eval_js(&format!(
29//!                         "js_function({}, {}, {})",
30//!                         1,
31//!                         "'two'",
32//!                         JsValue::String("𝟛\n".into()) // Gets properly formatted to a JS string
33//!                                                       // literal
34//!                     ));
35//!                 }
36//!                 "command_two" => {
37//!                     // ... do something else here ...
38//!                 }
39//!                 _ => {}
40//!             }
41//!         });
42//! 
43//!         bw.show();
44//! 	});
45//! 	app.finish();
46//! }
47//! ```
48//!
49//! For more detailed example code, see [this example code](https://github.com/bamidev/browser-window/tree/master/examples).
50//!
51//! # Thread safety
52//! To use the threadsafe version of _BrowserWindow_, enable feature
53//! `threadsafe`. This will use [`Arc`](https://doc.rust-lang.org/std/sync/struct.Arc.html)
54//! instead of [`Rc`](https://doc.rust-lang.org/std/rc/struct.Rc.html)
55//! internally, and will enable the
56//! [`BrowserWindowThreaded`](browser/struct.BrowserWindow.html) and
57//! [`ApplicationHandleThreaded`](browser/struct.BrowserWindowThreaded.html)
58//! handles. It will also require closures to be `Send`. Docs.rs will show the
59//! threadsafe versions of everything. If you need to know how everything is
60//! compiled in the non-threadsafe version, you need to invoke `cargo doc
61//! --open` in the git repo yourself.
62//!
63//! # Events
64//! To learn how to use events, take a quick look at the
65//! [`event`](event/index.html) module.
66
67mod core;
68#[cfg(test)]
69mod tests;
70
71pub mod application;
72pub mod browser;
73pub mod cookie;
74pub mod error;
75pub mod event;
76pub mod javascript;
77pub mod prelude;
78pub(crate) mod rc;
79pub mod window;
80
81#[cfg(feature = "threadsafe")]
82mod delegate;
83#[cfg(feature = "threadsafe")]
84pub use delegate::{DelegateError, DelegateFuture, DelegateFutureFuture};
85
86mod common;
87pub use common::*;