Skip to main content

Crate toac

Crate toac 

Source
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::Bodybody::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.
EncodeRequestError
Concrete std::error::Error wrapper around a BoxError.
WithAccept
Operation wrapper that overrides the Accept header the inner op would emit.
WithServer
Operation wrapper that routes this one call against a specific base URL, overriding whatever the hosting crate::ApiClient would otherwise prepend.

Enums§

CallError
Errors raised by ApiClient’s Service::call.
DecodeError
Shared error type used by every generated ParseResponse impl.

Traits§

MakeRequest
Converts a generated request value into a Request.
Operation
Couples a generated request type with its response enum.
ParseResponse
Decodes a generated response enum from any http::Response whose body frames carry bytes::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::ParseResponse implementations.