better-fetch-0.1.0 has been yanked.
better-fetch
Typed HTTP client layer on top of reqwest, inspired by @better-fetch/fetch. Independent Rust implementation.
Installation
Pick one crate name (same library):
[]
= "0.1"
= { = "1", = ["derive"] }
= { = "1", = ["macros", "rt-multi-thread"] }
Aliases on crates.io: typed-fetch, api-fetch — pub use better_fetch::*.
Quick start
use ;
use Deserialize;
async
Highlights
- Builder API —
Client::builder(), per-request.timeout(),.retry(),.auth(), headers, JSON body. - Retries — linear, exponential, or custom; hooks on retry.
- Hooks & plugins — compose client and plugin hooks; optional
LoggerPlugin(requires atracingsubscriber in your app). - Errors —
Result+?;Error::api_json()to parse JSON error bodies from APIs. - Typed endpoints —
Endpointtrait +client.call::<E>(). - Testing — inject
ClientBuilder::backend(Arc<dyn HttpBackend>).
Features
| Feature | Description |
|---|---|
reqwest, json, rustls-tls (default) |
Async client, JSON, TLS |
native-tls |
Platform TLS |
blocking, multipart, cookies |
Passed through to reqwest |
schema / openapi |
schemars registry and minimal OpenAPI document builder |
tower / tower-http |
Tower Service transport stack; see better-fetch-tower |
validate |
Response validation with garde (send_json_validated) |
macros |
Reserved better-fetch-macros crate |
Enable optional stacks in Cargo.toml, for example:
= { = "0.1", = ["tower", "validate"] }
See CHANGELOG.md for the full 0.1.0 scope.
Examples
Crates in this repository
| crates.io | Role |
|---|---|
| better-fetch | Main library |
| typed-fetch | Re-export alias |
| api-fetch | Re-export alias |
| better-fetch-tower | Tower transport helper |
| better-fetch-macros | Proc macros (reserved) |
License
MIT — see LICENSE. Upstream inspiration: THIRD_PARTY_NOTICES.md.