Expand description
§api-fetch
This crate is an alias for better-fetch: same types,
same API, alternate name on crates.io.
Modules§
- auth
- Authentication for clients and individual requests.
- backend
- HTTP transport abstraction.
- cancel
- Request cancellation (
CancellationToken) compatible with cooperative async abort. - client
- HTTP client, builder, and shared configuration.
- endpoint
- Typed API routes via the
Endpointtrait. - error
- Error types and helpers for HTTP, transport, hooks, and retries.
- hooks
- Lifecycle hooks for requests and responses.
- plugin
- Plugin hooks run after URL construction and auth, before request lifecycle hooks.
- plugins
- Built-in plugins.
- request
- Per-request fluent builder.
- response
- HTTP response wrapper with a fully buffered body.
- retry
- Retry policies for transport and HTTP failures.
- streaming
- Streaming HTTP responses (
send_stream).
Macros§
- define_
params - Defines path parameters for a route and implements
EndpointParams. - endpoint
- Defines a simple
Endpointwith optional typed params and query. - impl_
serde_ endpoint_ query - Implements
EndpointQueryfor a serde-serializable query struct (featurejson).
Structs§
- Cancellation
Token - A token which can be used to signal a cancellation request to one or more tasks.
- Client
- Typed HTTP client built on reqwest.
- Client
Builder - Builder for
Client. - Client
Config - Shared client configuration (returned by
Client::config). - Endpoint
Request Builder - Fluent builder for a typed
Endpoint. - Error
Context - Context when an error occurs.
- Hooks
- Lifecycle hooks for the HTTP client.
- Http
Request - Prepared HTTP request passed to a backend.
- Http
Response - Raw HTTP response from a backend (fully buffered).
- Http
Streaming Response - Raw HTTP response with a streaming body from a backend.
- Logger
Plugin - Tracing-based logger plugin (request, response, retry, error).
- Needs
Params - Type-state: path parameters still required before send.
- Plugin
Registry - Ordered plugin list.
- Prepared
Request - Prepared request state passed to plugin
Plugin::init. - Ready
- Type-state: ready to configure query/headers and send.
- Request
Builder - Fluent builder for a single HTTP request.
- Request
Context - Context for an outgoing request.
- Reqwest
Backend - Reqwest-backed HTTP backend.
- Response
- HTTP response wrapper.
- Response
Context - Context after a buffered response is received.
- Streaming
Response - HTTP response with a streaming body.
- Streaming
Response Context - Context after a streaming response is received (headers only; body not consumed).
- Streaming
Response Meta - Metadata returned from streaming response hooks.
- Streaming
Success Context - Context after a successful streaming response (2xx, metadata only).
- Success
Context - Context after a successful HTTP response (2xx).
Enums§
- Auth
- Authentication configuration for a client or request.
- Error
- Error type for better-fetch operations.
- Http
Body - Request body encoding for the transport layer.
- Query
Value - Query parameter value (scalar or repeated).
- Retry
Policy - Retry policy configuration.
- Token
Source - Source for credential values (static, sync, or async).
- Transport
Kind - Classification of underlying transport failures (connection, body, decode, etc.).
Traits§
- Async
Token Provider - Async token resolver.
- Endpoint
- Describes a typed API route.
- Endpoint
Params - Applies path parameters to a
RequestBuilder. - Endpoint
Params Initial - Creates the initial
EndpointRequestBuilderforclient.call::<E>(). - Endpoint
Query - Applies query parameters to a
RequestBuilder. - Http
Backend - Pluggable HTTP transport used by
Client. - Plugin
- Plugin extension point for better-fetch.
Functions§
- default_
should_ retry - Default HTTP status codes that trigger a retry when no custom predicate is set.
- json_
parser - Wraps a custom JSON parse function for use with
ClientBuilder::json_parser. - parse_
retry_ after - Parses
Retry-Afteras a delay in seconds (integer values only). - serde_
json_ parser - Default parser using
serde_json::from_slice(same semantics as the fast path, as aJsonParserFn).
Type Aliases§
- Body
Stream - Byte stream yielding
Result<Bytes>chunks from the transport. - Json
Parser Fn - Parses response bytes into
serde_json::Valuebefore deserializing toT. - Params
Builder State - Initial builder state for an endpoint’s path parameters.
- Result
- Result alias using
Error. - Should
Retry Fn - Predicate for whether a response should be retried.