oxigdal_websocket/lib.rs
1//! OxiGDAL WebSocket - Advanced Real-Time Communication
2//!
3//! This crate provides comprehensive WebSocket support for the OxiGDAL geospatial library,
4//! enabling real-time data streaming, broadcasting, and live updates.
5//!
6//! # Features
7//!
8//! - **WebSocket Server**: Full-featured server with connection management, heartbeat, and pooling
9//! - **Protocol Support**: Binary and JSON protocols with compression and framing
10//! - **Broadcasting**: Pub/sub channels, room management, and message filtering
11//! - **Live Updates**: Tile updates, feature changes, and change streams
12//! - **Client SDK**: JavaScript/TypeScript client with reconnection and caching
13//!
14//! # Examples
15//!
16//! ## Starting a WebSocket Server
17//!
18//! ```rust,no_run
19//! use oxigdal_websocket::server::Server;
20//!
21//! #[tokio::main]
22//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
23//! let server = Server::builder()
24//! .max_connections(10_000)
25//! .build();
26//!
27//! server.start().await?;
28//! Ok(())
29//! }
30//! ```
31//!
32//! ## Broadcasting Messages
33//!
34//! ```rust,no_run
35//! use oxigdal_websocket::broadcast::BroadcastSystem;
36//! use oxigdal_websocket::protocol::message::Message;
37//!
38//! # async fn example() -> oxigdal_websocket::error::Result<()> {
39//! let system = BroadcastSystem::new(Default::default());
40//!
41//! // Publish to a topic
42//! let message = Message::ping();
43//! system.publish("geospatial-updates", message).await?;
44//! # Ok(())
45//! # }
46//! ```
47
48#![deny(missing_docs)]
49#![warn(clippy::unwrap_used)]
50
51pub mod broadcast;
52pub mod client_sdk;
53pub mod error;
54pub mod protocol;
55pub mod server;
56pub mod updates;
57
58// Re-export commonly used types
59pub use broadcast::{BroadcastConfig, BroadcastSystem};
60pub use client_sdk::{
61 ClientSdkConfig, generate_javascript_client, generate_typescript_definitions,
62};
63pub use error::{Error, Result};
64pub use protocol::{Message, MessageFormat, MessageType, Payload, ProtocolCodec, ProtocolConfig};
65pub use server::{Server, ServerConfig};
66pub use updates::{
67 ChangeStream, FeatureUpdateManager, IncrementalUpdateManager, TileUpdateManager, UpdateConfig,
68 UpdateSystem,
69};
70
71/// Prelude module for convenient imports
72pub mod prelude {
73 pub use crate::broadcast::{BroadcastConfig, BroadcastSystem, Room, RoomManager};
74 pub use crate::client_sdk::{
75 ClientSdkConfig, generate_javascript_client, generate_typescript_definitions,
76 };
77 pub use crate::error::{Error, Result};
78 pub use crate::protocol::{
79 BinaryCodec, CompressionType, Message, MessageFormat, MessageType, Payload, ProtocolCodec,
80 ProtocolConfig,
81 };
82 pub use crate::server::{Connection, ConnectionId, HeartbeatConfig, Server, ServerConfig};
83 pub use crate::updates::{
84 ChangeStream, FeatureUpdate, IncrementalUpdate, TileUpdate, UpdateConfig, UpdateSystem,
85 };
86}
87
88#[cfg(test)]
89mod tests {
90 use super::*;
91
92 #[test]
93 fn test_exports() {
94 // Verify that key types are exported
95 let _: Option<Error> = None;
96 let _: Option<Message> = None;
97 }
98
99 #[test]
100 fn test_prelude_imports() {
101 use prelude::*;
102
103 // Verify that prelude imports work
104 let _ = ServerConfig::default();
105 let _ = ProtocolConfig::default();
106 let _ = BroadcastConfig::default();
107 let _ = UpdateConfig::default();
108 }
109}