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§

api_response
Helpers for typed success vs error response bodies.
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.
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.
prelude
Convenient re-exports for application code.
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).
NeedsBody
Type-state: request body required before send (POST with typed body via #[derive(Endpoint)]).
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.
RecordedRequest
Snapshot of a recorded HTTP request for assertions in tests.
RecordingBackend
Wraps an HttpBackend and records each executed request.
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).
RecordedBodyKind
Kind of request body last observed (streaming bodies are not replayed).
ResponseBodyKind
Parsed response body selected from Content-Type.
RetryPolicy
Retry policy configuration.
TokenSource
Source for credential values (static, sync, or async).
TransportKind
Classification of underlying transport failures (connection, body, decode, etc.).

Traits§

ApiResponseExt
Extension trait for Response.
AsyncTokenProvider
Async token resolver.
DefaultParamsInitial
Default () params initial state when E::Params is [()].
Endpoint
Describes a typed API route.
EndpointBody
Applies a typed request body before send.
EndpointHeaders
Applies typed default headers before send.
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§

build_url
Build a request URL from base URL, path template, params, and query.
default_should_retry
Default HTTP status codes that trigger a retry when no custom predicate is set.
into_api_result
Deserializes a buffered response into success T or API error E by HTTP status.
json_parser
Wraps a custom JSON parse function for use with ClientBuilder::json_parser.
parse_retry_after
Parses Retry-After as a delay.
path_param_names
Returns :param segment names in left-to-right path order (ignores an embedded ?query).
serde_json_parser
Default parser using serde_json::from_slice (same semantics as the fast path, as a JsonParserFn).
serialize_to_query_map
Converts a serializable struct into query parameters keyed by serde field names.

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.