deboa_extras/lib.rs
1//! # Deboa Extras
2//!
3//! `deboa-extras` is an extension crate for the `deboa` HTTP client that provides additional
4//! functionality and utilities for working with HTTP requests and responses.
5//!
6//! ## Features
7//!
8//! - **HTTP Utilities**: Additional HTTP-related functionality including:
9//! - Server-Sent Events (SSE) support
10//! - WebSocket client (when `websockets` feature is enabled)
11//! - Enhanced serialization/deserialization
12//! - **Compression**: Support for compressed request/response bodies (when `compression` feature is enabled)
13//! - **Error Handling**: Extended error types and utilities
14//! - **Catchers**: Pre-built error handlers for common scenarios
15//!
16//! ## Crate Features
17//!
18//! - `compression`: Enables compression support (gzip, deflate, brotli)
19//! - `websockets`: Enables WebSocket client functionality
20//! - `json`: Enables JSON serialization/deserialization
21//! - `msgpack`: Enables MessagePack serialization/deserialization
22//! - `xml`: Enables XML serialization/deserialization
23//!
24//! ## Examples
25//!
26//! ### Using Server-Sent Events (SSE)
27//!
28//! ```compile_fail
29//! use deboa_extras::http::sse::SseRequest;
30//! use futures_util::StreamExt;
31//!
32//! #[tokio::main]
33//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
34//! let mut client = deboa::Deboa::new();
35//! let sse = SseRequest::get("https://example.com/events")?;
36//! let mut stream = sse.send_with(&mut client).await?;
37//!
38//! while let Some(event) = stream.next().await {
39//! match event {
40//! Ok(event) => println!("Event: {:?}", event),
41//! Err(e) => eprintln!("Error: {}", e),
42//! }
43//! }
44//! Ok(())
45//! }
46//! ```
47//!
48//! ### Using WebSockets
49//!
50//! ```compile_fail
51//! use deboa_extras::ws::WebSocketRequest;
52//! use futures_util::{SinkExt, StreamExt};
53//!
54//! #[tokio::main]
55//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
56//! let mut client = deboa::Deboa::new();
57//! let (mut ws, _) = WebSocketRequest::connect("wss://echo.websocket.org").send_with(&mut client).await?;
58//!
59//! // Send a message
60//! ws.send("Hello, WebSocket!".into()).await?;
61//!
62//! // Receive messages
63//! while let Some(msg) = ws.next().await {
64//! match msg {
65//! Ok(msg) => println!("Received: {:?}", msg),
66//! Err(e) => eprintln!("Error: {}", e),
67//! }
68//! }
69//! Ok(())
70//! }
71//! ```
72
73pub mod catcher;
74pub mod errors;
75pub mod http;
76
77#[cfg(feature = "compression")]
78pub mod io;
79#[cfg(test)]
80mod tests;
81
82#[cfg(feature = "websockets")]
83pub mod ws;