Expand description
The ProviderAdapter trait (DW-075): the seam every provider
dialect implements and every higher layer composes on.
An adapter is a PURE TRANSLATOR. It holds no state, opens no
connections, and knows nothing about routing or failover — it turns
a ChatRequest into a provider
HTTP request shape, and provider JSON back into the canonical types.
Transport (endpoints, TLS, pooling, timeouts, breakers) belongs to
the named upstream; composing behaviors (DW-076 routing/failover,
DW-078 budgets) wrap the CALL, not the adapter — which is why the
trait has no I/O: composition layers stay free to retry or reroute a
translated request without re-translating.
Streaming (DW-077 wires the gateway side): adapters translate one
SSE data payload at a time via ProviderAdapter::parse_stream_event;
SSE framing itself is dialect-independent and lives in
crate::ai::sse.
Structs§
- Provider
Error Body - A provider error body normalized for pass-through.
- Provider
Request - A provider HTTP request produced by an adapter: everything the transport layer needs to place the call through the provider’s upstream. The URI is a PATH (+query) only — the upstream endpoint supplies the authority, exactly like a proxy route.
Enums§
- AiError
- The error type of the AI domain: client-side malformation, adapter translation failure, or a provider-reported error response.
Traits§
- Provider
Adapter - The translation contract of one provider dialect (DW-075). Pure
functions over the canonical types; implementations are stateless
singletons (see
adapter_for).
Functions§
- adapter_
for - The adapter singleton for a provider kind. Adapters are stateless — one instance per dialect serves every request.