Skip to main content

cloud_sdk/transport/
asynchronous.rs

1//! Runtime-neutral asynchronous transport contract.
2
3use core::future::Future;
4
5use super::{TransportRequest, TransportResponse};
6
7/// Asynchronous transport over caller-owned request and response buffers.
8///
9/// The contract does not select an executor, allocator, HTTP client, TLS
10/// implementation, clock, or retry policy. Adapter crates document any runtime
11/// requirements they add.
12///
13/// The shared receiver does not create concurrency. Callers may overlap or
14/// spawn returned futures only when the concrete implementation and future
15/// satisfy their executor's `Sync`, `Send`, and lifetime requirements.
16///
17/// Implementations must treat cancellation as an error path: dropping the
18/// returned future must not expose a partially initialized response as a
19/// successful [`TransportResponse`]. Implementations handling secret response
20/// data should also clear temporary owned storage when the future is dropped.
21pub trait AsyncTransport {
22    /// Transport-specific failure.
23    type Error;
24
25    /// Sends one request and initializes the complete response body in the
26    /// caller buffer.
27    fn send<'transport, 'request, 'buffer>(
28        &'transport self,
29        request: TransportRequest<'request>,
30        response_body: &'buffer mut [u8],
31    ) -> impl Future<Output = Result<TransportResponse<'buffer>, Self::Error>> + Send + 'transport
32    where
33        'request: 'transport,
34        'buffer: 'transport;
35}