http_request/request/http_request/trait.rs
1use crate::*;
2
3/// Combines AsyncRead and AsyncWrite traits with Unpin and Send bounds.
4///
5/// Provides a unified trait for asynchronous read/write operations.
6pub(crate) trait AsyncReadWrite: AsyncRead + AsyncWrite + Unpin + Send {}
7
8/// Combines Read and Write traits.
9///
10/// Provides a unified trait for synchronous read/write operations.
11pub(crate) trait ReadWrite: Read + Write {}
12
13/// Asynchronous HTTP request trait.
14///
15/// Defines the interface for sending asynchronous HTTP requests.
16pub trait AsyncRequestTrait: Send + Debug {
17 /// The result type of the asynchronous request.
18 type RequestResult: Sized;
19
20 /// Sends the HTTP request asynchronously.
21 ///
22 /// # Returns
23 ///
24 /// - `Pin<Box<dyn Future<Output = Self::RequestResult> + Send + '_>>` -
25 /// A pinned boxed future representing the asynchronous operation.
26 fn send(&mut self) -> Pin<Box<dyn Future<Output = Self::RequestResult> + Send + '_>>;
27}
28
29/// Synchronous HTTP request trait.
30///
31/// Defines the interface for sending synchronous HTTP requests.
32pub trait RequestTrait: Send + Debug {
33 /// The result type of the synchronous request.
34 type RequestResult: Sized;
35
36 /// Sends the HTTP request synchronously.
37 ///
38 /// # Returns
39 ///
40 /// - `Self::RequestResult` - The result of the synchronous request.
41 fn send(&mut self) -> Self::RequestResult;
42}