pub trait HttpTransport:
Send
+ Sync
+ Clone
+ 'static {
// Required method
fn request(&self, request: Request<Option<Bytes>>) -> ResponseFuture;
}Expand description
Trait for pluggable HTTP transport implementations.
Implement this trait to provide HTTP request/response functionality. The transport is responsible for:
- Establishing HTTP connections (with TLS if needed)
- Sending HTTP requests
- Returning streaming HTTP responses
- Handling timeouts (if desired)
§Example
use launchdarkly_sdk_transport::{HttpTransport, ByteStream, TransportError, Request,
ResponseFuture};
use bytes::Bytes;
#[derive(Clone)]
struct MyTransport {
// Your HTTP client here
}
impl HttpTransport for MyTransport {
fn request(&self, request: Request<Option<Bytes>>) -> ResponseFuture {
// Extract body from request
// Convert request to your HTTP client's format
// Make the request
// Return streaming response
todo!()
}
}Required Methods§
Sourcefn request(&self, request: Request<Option<Bytes>>) -> ResponseFuture
fn request(&self, request: Request<Option<Bytes>>) -> ResponseFuture
Execute an HTTP request and return a streaming response.
§Arguments
request- The HTTP request to execute. The body type isOption<Bytes>to support methods like REPORT that may include a request body. UseNonefor requests without a body (like GET).Bytescan contain either text or binary data.
§Returns
A future that resolves to an HTTP response with a streaming body, or a transport error if the request fails.
The response should include:
- Status code
- Response headers
- A stream of body bytes
§Notes
- The transport should NOT follow redirects. This should be left to the consumer.
- The transport should NOT retry requests. This should also be left to the consumer.
- The transport MAY implement timeouts as desired
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".