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
//! web adapter — bidirectional streaming between a wingfoil graph and
//! one or more browsers over WebSocket.
//!
//! The [`WebServer`] hosts an HTTP + WebSocket listener in its own
//! dedicated tokio runtime (same pattern as the Prometheus exporter).
//! Graph nodes register topics on the server:
//!
//! - [`web_pub`] — publishes a stream's values to every client that
//! subscribes to the topic.
//! - [`web_sub`] — exposes frames sent by the browser on a topic as a
//! wingfoil [`Stream`](crate::Stream).
//!
//! Binary frames use [`bincode`](https://docs.rs/bincode) by default;
//! pass [`CodecKind::Json`] for a human-readable mode useful for
//! debugging in the browser devtools. The shared [`Envelope`] type is
//! declared in the [`wingfoil-wire-types`](wingfoil_wire_types) crate
//! so the server binary and the `wingfoil-wasm` browser client can
//! share a single source of truth.
//!
//! # Publishing
//!
//! ```ignore
//! use wingfoil::*;
//! use wingfoil::adapters::web::*;
//! use std::time::Duration;
//!
//! let server = WebServer::bind("127.0.0.1:0").start().unwrap();
//! let port = server.port();
//! println!("open ws://127.0.0.1:{port}/ws");
//!
//! ticker(Duration::from_millis(10))
//! .count()
//! .web_pub(&server, "tick")
//! .run(RunMode::RealTime, RunFor::Forever)
//! .unwrap();
//! ```
//!
//! # Subscribing (browser → graph)
//!
//! ```ignore
//! use wingfoil::*;
//! use wingfoil::adapters::web::*;
//!
//! let server = WebServer::bind("127.0.0.1:0").start().unwrap();
//! let clicks: std::rc::Rc<dyn Stream<Burst<u32>>> = web_sub(&server, "ui_events");
//! clicks.collapse().print().run(RunMode::RealTime, RunFor::Forever).unwrap();
//! ```
//!
//! # Serving a static UI bundle
//!
//! ```ignore
//! let server = WebServer::bind("127.0.0.1:3000")
//! .serve_static("./wingfoil-js/dist")
//! .start()
//! .unwrap();
//! ```
//!
//! # HTTPS / WSS (rustls)
//!
//! Enable the `web-tls` cargo feature and chain `.tls(cert, key)` onto
//! the builder. Cert and key are PEM files on disk; the rustls crypto
//! provider is `ring`, matching the FIX adapter. Clients must connect
//! via `https://` / `wss://`. The `wingfoil-js` browser client honours
//! `location.protocol`, so the only client-side change is loading the
//! page over HTTPS.
//!
//! ```ignore
//! let server = WebServer::bind("0.0.0.0:8080")
//! .serve_static("./dist")
//! .tls("/etc/wingfoil/tls/cert.pem", "/etc/wingfoil/tls/key.pem")
//! .start()
//! .unwrap();
//! ```
//!
//! # Historical mode
//!
//! The server exposes [`WebServerBuilder::start_historical`] for use in
//! `RunMode::HistoricalFrom` runs. No TCP port is bound and all
//! publishes / subscribes become no-ops, so the same graph can run
//! under both real-time and historical modes without modification.
pub use ;
pub use web_sub;
pub use ;
pub use ;