reqwest-enum
Type-safe and enum style API for Rust, some benefits:
- It abstracts away repetitive boilerplate code like url formatting, query / header encoding and response deserialization.
- Type-safe endpoints, readable like a spec, easy to add new or refactor existing endpoints.
- Async by default and lightweight JSON-RPC support.
Features:
- Type-safe and enum style HTTP API
- JSON-RPC with batching support
- ...
Installation
cargo add reqwest-enum
or add it to your Cargo.toml
:
[]
= "0.2.0"
Example
httpbin.org
- Define endpoints for https://httbin.org as an enum:
- Implement
Target
for the enum:
- Create a provider and request:
let provider = default;
let response = provider.request.await.unwrap;
assert_eq!;
JSON-RPC
Full example can be found in examples/ethereum-rpc.
- Define Ethereum JSON-RPC methods as an enum:
- Implement
Target
andJsonRpcTarger
for the enum:
- Create a provider and request:
let provider = default;
let response: =
provider.request_json.await.unwrap;
assert_eq!;
License
MIT or Apache-2.0