Skip to main content

flare_core/server/
mod.rs

1//! Native server runtime for WebSocket, QUIC, TCP, and hybrid listeners.
2//!
3//! The server module is available on native targets when the `server` feature is
4//! enabled. It provides:
5//!
6//! - [`FlareServerBuilder`] for production integrations built around
7//!   [`ServerEventHandler`], authentication, message pipelines, and connection
8//!   lifecycle hooks.
9//! - [`ServerBuilder`] for closure-based demos and compact prototypes.
10//! - [`ObserverServerBuilder`] for integrations that need explicit connection
11//!   observation.
12//! - [`ConnectionManager`] and [`ServerHandle`] for sending frames, broadcasting,
13//!   disconnecting clients, and inspecting connection snapshots.
14//!
15//! The server stack owns transport admission, negotiation, heartbeat detection,
16//! backpressure-aware fanout, and cleanup. Business-specific message semantics
17//! should remain in application handlers or higher-level services.
18
19#[cfg(not(any(feature = "websocket", feature = "quic", feature = "tcp")))]
20compile_error!(
21    "feature `server` requires at least one transport feature: `websocket`, `quic`, or `tcp`"
22);
23
24pub mod auth;
25pub mod builder;
26pub mod config;
27pub mod connection;
28pub mod device;
29pub mod events;
30pub mod handle;
31pub mod heartbeat;
32pub mod transports;
33
34pub use auth::{AuthResult, Authenticator, DefaultAuthenticator};
35pub use builder::{
36    FlareServer, FlareServerBuilder, MessageContext, ObserverServer, ObserverServerBuilder,
37    ServerBuilder, SimpleServer,
38};
39pub use config::ServerConfig;
40pub use connection::{ConnectionInfo, ConnectionManager, ConnectionManagerTrait, ConnectionStats};
41pub use device::{DeviceConflictStrategy, DeviceConflictStrategyBuilder, DeviceManager};
42pub use events::ServerEventHandler;
43pub use handle::{DefaultServerHandle, ServerHandle};
44pub use heartbeat::HeartbeatDetector;
45#[cfg(feature = "quic")]
46pub use transports::QUICServer;
47#[cfg(feature = "tcp")]
48pub use transports::TCPServer;
49#[cfg(feature = "websocket")]
50pub use transports::WebSocketServer;
51pub use transports::{ConnectionHandler, HybridServer, Server};
52
53// Re-export server-oriented error types for ergonomic imports.
54pub use crate::common::error::Result;
55pub use crate::common::error::ServerError;
56
57pub use crate::common::config_types::TransportProtocol;