airkorea-rs

circleci crate.io docs.rs License: MIT License: Apache-2.0

Airkorea Crawler written in Rust.

Usage

```rust use {airkorea, futures::prelude::*, tokio::runtime::Runtime};

let mut rt = Runtime::new();

let status = rt.block_on(airkorea::search(lng, lat))?;

println!("Station address: {}", status.station_address); println!("Time: {}", status.time); for pollutant in status { println!("{}", pollutant); } ```

Testing

You can override Airkorea Url for mock testing. If you want to write unit tests for some functions using airkorea, just set AIRKOREA_URL environment variable to desired mock server.

```rust spawn_server("localhost:1234");

std::env::setvar("AIRKOREAURL", "http://localhost:1234");

let status = rt.block_on(airkorea::search(123.123, 456.456)).unwrap();

asserteq!(&status.stationaddress, "Foobar Station"); ```