Announcing lta-rs v0.3.0
ZEON256
2019-11-01 1 min read
rust lta async api
AI Summary
Announcing lta-rs v0.3.0, a Rust client for Singapore's Datamall APIs. Key changes include refactoring modules into separate async/blocking crates, adding async/await support, migrating CI from Travis to Azure Pipelines, and an example showing how to fetch bus arrival data using the new async API.
I would like to announce the arrival of lta-rs v0.3.0!
lta-rs is a client to interact with Singapore’s Datamall APIs implemented in Rust. In this version, there were quite a few changes and let me go through some of the highlights
- Refactored modules to separate crates which can be enabled by features
asyncandblocking - Added support for
async/await. Internally, the whole library usesasync/awaitto simplify writing asynchronous programs - General internal code clean up
In terms of development, lta-rs has moved on from travis.ci to Azure Pipelines to
have more insights regarding compilation on Windows and MacOS.
lta-rs async/await in action
Put this in your cargo.toml
[dependencies]
lta = { version = "0.3.0", features = ["async"] }
use std:: env;
use lta:: prelude:: * ;
use lta:: r#async::{
bus:: get_arrival,
lta_client:: LTAClient
};
# [ tokio :: main ]
async fn main () -> LTAResult <()> {
let api_key = env:: var ( "API_KEY" ). expect ( "API_KEY must be set!" );
let client = LTAClient :: with_api_key ( api_key);
let arrivals_one = get_arrival ( & client, 83139 , None ). await ?;
let arrivals_two = get_arrival ( & client, 83139 , None ). await ?;
println! ( "{:?} \n{:?}" , arrivals_one, arrivals_two);
Ok (())
} I would like to thank those who have supported me in building library. That’s all folks!