pub struct HttpTransport { /* private fields */ }
Expand description
Reqwest-based HTTP transport implementation, encapsulating all HTTP details
HTTP transport implementation based on reqwest, encapsulating all HTTP details
This is the concrete implementation of the HttpClient trait, encapsulating all HTTP details
Implementations§
Source§impl HttpTransport
impl HttpTransport
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new HTTP transport instance
Automatically detects AI_PROXY_URL environment variable for proxy configuration
Note: This method will always check for AI_PROXY_URL environment variable.
If you want to avoid automatic proxy detection, use new_without_proxy()
instead.
Sourcepub fn new_without_proxy() -> Self
pub fn new_without_proxy() -> Self
Create new HTTP transport instance without automatic proxy detection
This method creates a transport instance without checking AI_PROXY_URL environment variable. Use this when you want explicit control over proxy configuration.
Sourcepub fn with_timeout(timeout: Duration) -> Self
pub fn with_timeout(timeout: Duration) -> Self
Create HTTP transport instance with timeout
Automatically detects AI_PROXY_URL environment variable for proxy configuration
Sourcepub fn with_timeout_without_proxy(timeout: Duration) -> Self
pub fn with_timeout_without_proxy(timeout: Duration) -> Self
Create HTTP transport instance with timeout without automatic proxy detection
This method creates a transport instance with timeout but without checking AI_PROXY_URL environment variable.
Sourcepub fn with_client(client: Client, timeout: Duration) -> Self
pub fn with_client(client: Client, timeout: Duration) -> Self
Create an instance from an existing reqwest::Client (injected)
Examples found in repository?
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 // Build a reqwest client with custom pool settings
9 let reqwest_client = Client::builder()
10 .pool_max_idle_per_host(32)
11 .pool_idle_timeout(Duration::from_secs(90))
12 .timeout(Duration::from_secs(30))
13 .build()?;
14
15 // Wrap into library transport and inject
16 let transport = HttpTransport::with_client(reqwest_client, Duration::from_secs(30));
17
18 let config = ProviderConfigs::groq();
19 let _adapter = GenericAdapter::with_transport(config, transport)?;
20
21 println!("Created generic adapter with custom transport");
22 Ok(())
23}
Sourcepub fn with_reqwest_client(client: Client, timeout: Duration) -> Self
pub fn with_reqwest_client(client: Client, timeout: Duration) -> Self
Convenience alias that makes the intent explicit: create from a pre-built reqwest::Client.
This is a small, descriptive wrapper around with_client
that callers may find more
discoverable when constructing transports from an external reqwest::Client
.
Sourcepub fn new_with_config(
config: HttpTransportConfig,
) -> Result<Self, TransportError>
pub fn new_with_config( config: HttpTransportConfig, ) -> Result<Self, TransportError>
Create instance using HttpTransportConfig
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let cfg = HttpTransportConfig {
8 timeout: Duration::from_secs(30),
9 proxy: None,
10 pool_max_idle_per_host: Some(16),
11 pool_idle_timeout: Some(Duration::from_secs(60)),
12 };
13
14 let transport = HttpTransport::new_with_config(cfg)?;
15 let provider_cfg = ProviderConfigs::groq();
16 let _adapter = GenericAdapter::with_transport(provider_cfg, transport)?;
17
18 println!("Created adapter using HttpTransportConfig");
19 Ok(())
20}
Sourcepub fn with_proxy(
timeout: Duration,
proxy_url: Option<&str>,
) -> Result<Self, TransportError>
pub fn with_proxy( timeout: Duration, proxy_url: Option<&str>, ) -> Result<Self, TransportError>
Create HTTP transport instance with custom proxy
Source§impl HttpTransport
impl HttpTransport
Sourcepub fn boxed(self) -> DynHttpTransportRef
pub fn boxed(self) -> DynHttpTransportRef
Produce an Arc-wrapped object-safe transport reference