1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//! # Compression I/O Module
//!
//! This module provides compression functionality for HTTP requests and responses.
//! It defines a `Compressor` trait that allows for different compression algorithms
//! to be implemented and used with the Deboa HTTP client.
//!
//! ## Purpose
//!
//! The compression module enables automatic compression of request bodies to reduce
//! bandwidth usage and improve performance when sending large payloads.
//!
//! ## Usage
//!
//! Implement the `Compressor` trait for your desired compression algorithm:
//!
//! ```rust, ignore
//! use deboa::fs::io::Compressor;
//! use async_trait::async_trait;
//! use bytes::Bytes;
//! use deboa::{request::DeboaRequest, Result};
//!
//! #[async_trait]
//! impl Compressor for MyCompressor {
//! fn name(&self) -> String {
//! "my-compression".to_string()
//! }
//!
//! async fn compress_body(&self, request: &DeboaRequest) -> Result<Bytes> {
//! // Implement compression logic here
//! Ok(Bytes::from("compressed-data"))
//! }
//! }
//! ```
//!
//! ## Supported Features
//!
//! - Async compression operations
//! - Thread-safe implementations (`Send + Sync`)
//! - Custom compression algorithms
//! - Integration with HTTP request pipeline
use async_trait;
use Bytes;
use crate::;
/// Trait that represents a compression algorithm for HTTP request bodies.
///
/// This trait defines the interface that all compression implementations must follow.
/// It enables automatic compression of request payloads to reduce bandwidth usage
/// and improve transfer speeds.
///
/// # Requirements
///
/// Implementations must be:
/// - `Send`: Safe to transfer across thread boundaries
/// - `Sync`: Safe to share between threads
/// - `'static`: Valid for the entire lifetime of the program
///
/// # Examples
///
/// ```rust, ignore
/// use deboa::fs::io::Compressor;
/// use async_trait::async_trait;
/// use bytes::Bytes;
/// use deboa::{request::DeboaRequest, Result};
///
/// struct GzipCompressor;
///
/// #[async_trait]
/// impl Compressor for GzipCompressor {
/// fn name(&self) -> String {
/// "gzip".to_string()
/// }
///
/// async fn compress_body(&self, request: &DeboaRequest) -> Result<Bytes> {
/// // Implement gzip compression
/// Ok(request.body().clone())
/// }
/// }
/// ```
/// Trait that represents the decompressor.