Expand description
Tower-compatible OpenAPI client runtime.
toac is the library half of the code-generation/runtime split: the
toac-build crate emits Rust code at build time, and the generated
code links against the types and traits defined here.
The runtime pins a single pair of transport types — Request and
Response — both parameterised over the erased body::Body
defined in this crate. Every generated {Op}Request implements
MakeRequest to encode itself into a Request, and every
generated {Op}Response implements ParseResponse to decode a
Response into a typed variant. ApiClient wraps a
tower::Service that speaks Request → Response and adapts it to
Service<Op>, so callers drive the API through typed operation
values.
Because the body type is fixed, the inner transport just needs to
accept a Request and return a Response. Adapting an arbitrary
HTTP client (hyper, reqwest, etc.) usually means a single
tower::Service layer that converts between the foreign body and
body::Body — body::Body::new accepts any
http_body::Body<Data = Bytes> whose error is convertible into
BoxError.
Re-exports§
pub use request::Request;pub use security::AuthSelector;pub use security::NoAuth;pub use security::OperationSecurity;pub use security::SecurityCredential;
Modules§
- body
- Erased body type used across the runtime surface.
- compat
- Backend-compatibility adapters.
- request
- security
- Security / auth scaffolding.
Macros§
- include_
client - Includes a generated client module produced by
toac_build::Builder.
Structs§
- ApiClient
- Tower service that turns typed operation requests into HTTP exchanges.
- Encode
Request Error - Concrete
std::error::Errorwrapper around aBoxError. - With
Accept - Operation wrapper that overrides the
Acceptheader the inner op would emit. - With
Server - Operation wrapper that routes this one call against a specific
base URL, overriding whatever the hosting
crate::ApiClientwould otherwise prepend.
Enums§
- Call
Error - Errors raised by
ApiClient’sService::call. - Decode
Error - Shared error type used by every generated
ParseResponseimpl.
Traits§
- Make
Request - Converts a generated request value into a
Request. - Operation
- Couples a generated request type with its response enum.
- Parse
Response - Decodes a generated response enum from any
http::Responsewhose body frames carrybytes::Bytes. - Server
- Produces a base URL for every outgoing request.
Type Aliases§
- BoxError
- Erased error used across the runtime surface.
- Response
- HTTP response type consumed by
crate::ParseResponseimplementations.