Skip to main content

Crate api_fetch

Crate api_fetch 

Source
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 Endpoint trait.
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 buffered body.
retry
Retry policies for transport and HTTP failures.

Macros§

endpoint
Defines a simple Endpoint with no params or query.

Structs§

CancellationToken
A token which can be used to signal a cancellation request to one or more tasks.
Client
Typed HTTP client built on reqwest.
ClientBuilder
Builder for Client.
ClientConfig
Shared client configuration (returned by Client::config).
EndpointRequestBuilder
Fluent builder for a typed Endpoint.
ErrorContext
Context when an error occurs.
Hooks
Lifecycle hooks for the HTTP client.
HttpRequest
Prepared HTTP request passed to a backend.
HttpResponse
Raw HTTP response from a backend.
LoggerPlugin
Tracing-based logger plugin (request, response, retry, error).
PluginRegistry
Ordered plugin list.
PreparedRequest
Prepared request state passed to plugin Plugin::init.
RequestBuilder
Fluent builder for a single HTTP request.
RequestContext
Context for an outgoing request.
ReqwestBackend
Reqwest-backed HTTP backend.
Response
HTTP response wrapper.
ResponseContext
Context after a response is received.
SuccessContext
Context after a successful HTTP response (2xx).

Enums§

Auth
Authentication configuration for a client or request.
Error
Error type for better-fetch operations.
HttpBody
Request body encoding for the transport layer.
QueryValue
Query parameter value (scalar or repeated).
RetryPolicy
Retry policy configuration.
TokenSource
Source for credential values (static, sync, or async).

Traits§

AsyncTokenProvider
Async token resolver.
Endpoint
Describes a typed API route.
EndpointParams
Applies path parameters to a RequestBuilder.
EndpointQuery
Applies query parameters to a RequestBuilder.
HttpBackend
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-After as a delay in seconds (integer values only).
serde_json_parser
Default parser using serde_json::from_slice (same semantics as the fast path, as a JsonParserFn).

Type Aliases§

JsonParserFn
Parses response bytes into serde_json::Value before deserializing to T.
Result
Result alias using Error.
ShouldRetryFn
Predicate for whether a response should be retried.