http_request/request/proxy/struct.rs
1use super::*;
2
3/// Proxy configuration for an outgoing HTTP / WebSocket request.
4///
5/// `Proxy` is a value type with no `Arc<RwLock>` wrapping — exactly like
6/// `hyperlane-core`'s plain fields. Construct one with the convenience
7/// constructors below, then pass to `RequestBuilder::proxy(...)` or assign
8/// directly to `RequestConfig::proxy`.
9///
10/// # Examples
11///
12/// ```ignore
13/// use http_request::Proxy;
14///
15/// let p = Proxy::https("proxy.example.com", 7890);
16/// let auth = Proxy::socks5("127.0.0.1", 1080).auth("user", "pass");
17/// ```
18#[derive(Clone, Data, Debug, Eq, PartialEq)]
19pub struct Proxy {
20 /// Proxy protocol family.
21 pub proxy_type: ProxyType,
22 /// Proxy server hostname or IP.
23 pub host: String,
24 /// Proxy server port.
25 pub port: u16,
26 /// Optional username for proxy auth.
27 #[get(type(clone))]
28 pub username: Option<String>,
29 /// Optional password for proxy auth.
30 #[get(type(clone))]
31 pub password: Option<String>,
32}
33
34/// Async tunnel stream wrapping another async stream, with a buffer of
35/// pre-read bytes that are returned before delegating to the inner stream.
36#[derive(Data)]
37pub struct ProxyTunnelStream {
38 #[get(pub(super))]
39 #[get_mut(pub(super))]
40 #[set(pub(super))]
41 pub(super) inner: BoxAsyncReadWrite,
42 #[get(pub(super))]
43 #[get_mut(pub(super))]
44 #[set(pub(super))]
45 pub(super) pre_read_data: Vec<u8>,
46}
47
48/// Sync tunnel stream wrapping another sync stream, with a buffer of
49/// pre-read bytes that are returned before delegating to the inner stream.
50#[derive(Data)]
51pub struct SyncProxyTunnelStream {
52 #[get(pub(super))]
53 #[get_mut(pub(super))]
54 #[set(pub(super))]
55 pub(super) inner: BoxReadWrite,
56 #[get(pub(super))]
57 #[get_mut(pub(super))]
58 #[set(pub(super))]
59 pub(super) pre_read_data: Vec<u8>,
60}