Skip to main content

http_request/request/http_request/
trait.rs

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