1#![forbid(unsafe_code)]
6#![warn(missing_docs)]
7
8pub mod auth;
10pub mod events;
12mod middleware;
13pub mod rpc;
15mod server;
16
17#[cfg(feature = "ui")]
19pub mod ui_server;
20
21pub use auth::{AuthConfig, AuthError, AuthState, User, UserRole, UserStore};
22pub use events::{EventBroadcaster, UiEvent, UiEventEnvelope};
23pub use middleware::GatewayRateLimiter;
24pub use rpc::{RpcError, RpcRequest, RpcResponse};
25pub use server::{Gateway, GatewayBuilder, GatewayConfig, GatewayState};
26
27#[cfg(feature = "ui")]
28pub use ui_server::UiServerConfig;
29
30pub async fn start(config: GatewayConfig) -> Result<(), GatewayError> {
36 let gateway = Gateway::new(config)?;
37 gateway.run().await
38}
39
40#[derive(Debug, thiserror::Error)]
42pub enum GatewayError {
43 #[error("Server error: {0}")]
45 Server(String),
46
47 #[error("Config error: {0}")]
49 Config(String),
50
51 #[error("IO error: {0}")]
53 Io(#[from] std::io::Error),
54}