2 releases
0.1.1 | Jul 11, 2021 |
---|---|
0.1.0 | Jul 3, 2021 |
#7 in #nation
13KB
283 lines
NationStates API Wrapper in Rust
Rust crate for easily interacting with the NationStates API in rust.
lib.rs
:
NationStates API in Rust
This crate consists of a wrapper around the api of the game NationStates. Still a work in progress, currently only supports the standard api's for the nation and region endpoints. The NationStates API documentation is available here.
Example
use nationstates::{NSClient, NSError};
#[tokio::main]
pub async fn main() -> Result<(), NSError> {
let mut client = NSClient::new("Owl Archipelago's API Test")?;
let nation = client.get_nation("Owl Archipelago").await?;
println!("{}", nation.name);
println!("{}", nation.fullname);
println!("{}", nation.motto);
if nation.in_wa() {
println!("WA Member");
}
println!("{} - {}", nation.founded, nation.firstlogin.to_string());
println!();
println!("Economic Freedom: {}", nation.freedom.economy);
println!();
for cause in nation.deaths.causes {
println!("{} - {}", cause.reason, cause.percentage);
}
println!();
println!("Endo Count: {}", nation.endorsements.count());
for endo in nation.endorsements.get() {
println!("{}", endo);
}
Ok(())
}
Dependencies
~8–20MB
~285K SLoC