Install
Add nea-rs and the satay-reqwest adapter (plus reqwest and tokio for the async example below):
These commands write the latest compatible versions into Cargo.toml for you. Recent reqwest releases use rustls by default, so HTTPS works without an extra TLS feature. If your app needs blocking clients, proxies, or other transport options, keep a direct reqwest dependency and enable features there. See Using other client backends and the Satay transport docs.
Example
Fetch the latest air temperature readings with reqwest and satay-reqwest:
use Api;
use ReqwestActionExt;
use Client;
use env;
use Error;
async
From this repo, run the same logic as a binary example:
Optional: set X_API_KEY to your data.gov.sg API key. More runnable examples live under examples/.
Using other client backends
nea-rs is sans-IO: generated actions build http::Request<Vec<u8>> values and decode responses without performing IO. Pick the HTTP client that fits your application, or use the same boundary directly in tests, WASM, or custom transports.
See satay-rs for more details
ureq
use Api;
use UreqActionExt;
use ureq;
use env;
use Error;
Configure the agent with http_status_as_error(false) so Satay can decode typed non-2xx responses instead of ureq treating them as transport errors.
reqwest (blocking)
Enable the blocking feature on both crates when you want a synchronous reqwest client:
use Api;
use ReqwestBlockingActionExt;
use blocking;
use env;
use Error;
For more transport patterns (including WebSocket and custom adapters), see the Satay transport docs and the examples under satay-rs/examples/.
More examples
If you would like to see more examples, take a look at the examples folder
Security
Please see SECURITY.md for vulnerability reporting.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.