Skip to main content

flare_core/client/
mod.rs

1//! Client-side builders, transports, heartbeat management, and connection state.
2//!
3//! Native builds support WebSocket, QUIC, TCP, and hybrid protocol racing depending
4//! on enabled features. WASM builds support the browser WebSocket client stack.
5//!
6//! Main entry points:
7//!
8//! - `FlareClientBuilder` for production integrations with a message listener
9//!   and pipeline-oriented lifecycle.
10//! - `ClientBuilder` for closure-based examples and simple applications.
11//! - `ObserverClientBuilder` for native integrations that need explicit
12//!   connection observation and protocol racing.
13//! - `HybridClient` for native transport racing when multiple protocols are
14//!   available.
15//!
16//! WASM integrators: read [`crate::transport::connection`] for `Send`/`Sync` and LocalSet rules,
17//! and use the wasm async helpers re-exported by this module for browser entry points.
18
19#[cfg(not(any(
20    feature = "websocket",
21    all(feature = "quic", not(target_arch = "wasm32")),
22    all(feature = "tcp", not(target_arch = "wasm32"))
23)))]
24compile_error!(
25    "feature `client` requires at least one transport feature: `websocket`, native `quic`, or native `tcp`"
26);
27
28pub mod builder;
29pub mod config;
30pub mod connection;
31pub mod events;
32pub mod heartbeat;
33pub mod router;
34pub mod runtime;
35pub mod transports;
36#[cfg(target_arch = "wasm32")]
37pub mod wasm_tokio;
38
39#[cfg(not(target_arch = "wasm32"))]
40pub mod manager;
41
42pub use builder::{ClientBuilder, FlareClient, FlareClientBuilder, MessageListener, SimpleClient};
43pub use config::ClientConfig;
44pub use connection::{ConnectionState, ConnectionStateManager};
45pub use events::{ClientEventHandler, DefaultClientMessageObserver};
46pub use heartbeat::HeartbeatManager;
47pub use router::{AsyncHandler, MessageHandler, MessageRouter, SimpleHandler};
48pub use transports::Client;
49#[cfg(feature = "websocket")]
50pub use transports::WebSocketClient;
51
52#[cfg(target_arch = "wasm32")]
53pub use wasm_tokio::{
54    ensure_initialized as ensure_wasm_tokio, run_async as run_wasm_async,
55    spawn_detached as spawn_wasm_detached,
56};
57
58#[cfg(not(target_arch = "wasm32"))]
59pub use builder::{ObserverClient, ObserverClientBuilder};
60#[cfg(not(target_arch = "wasm32"))]
61pub use manager::ClientConnectionManager;
62#[cfg(all(
63    not(target_arch = "wasm32"),
64    any(feature = "websocket", feature = "quic", feature = "tcp")
65))]
66pub use transports::HybridClient;
67#[cfg(all(not(target_arch = "wasm32"), feature = "quic"))]
68pub use transports::QUICClient;
69#[cfg(all(not(target_arch = "wasm32"), feature = "tcp"))]
70pub use transports::TCPClient;
71
72pub use crate::common::config_types::TransportProtocol;
73pub use crate::common::error::ClientError;
74pub use crate::common::error::Result;