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 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 Endpoint with optional typed params and query.
impl_serde_endpoint_query
Implements EndpointQuery for a serde-serializable query struct (feature json).

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 (fully buffered).
HttpStreamingResponse
Raw HTTP response with a streaming body from a backend.
LoggerPlugin
Tracing-based logger plugin (request, response, retry, error).
NeedsParams
Type-state: path parameters still required before send.
PluginRegistry
Ordered plugin list.
PreparedRequest
Prepared request state passed to plugin Plugin::init.
Ready
Type-state: ready to configure query/headers and send.
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 buffered response is received.
StreamingResponse
HTTP response with a streaming body.
StreamingResponseContext
Context after a streaming response is received (headers only; body not consumed).
StreamingResponseMeta
Metadata returned from streaming response hooks.
StreamingSuccessContext
Context after a successful streaming response (2xx, metadata only).
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).
TransportKind
Classification of underlying transport failures (connection, body, decode, etc.).

Traits§

AsyncTokenProvider
Async token resolver.
Endpoint
Describes a typed API route.
EndpointParams
Applies path parameters to a RequestBuilder.
EndpointParamsInitial
Creates the initial EndpointRequestBuilder for client.call::<E>().
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§

BodyStream
Byte stream yielding Result<Bytes> chunks from the transport.
JsonParserFn
Parses response bytes into serde_json::Value before deserializing to T.
ParamsBuilderState
Initial builder state for an endpoint’s path parameters.
Result
Result alias using Error.
ShouldRetryFn
Predicate for whether a response should be retried.