auto-traffic-control

Crates.ioauto-traffic-control
lib.rsauto-traffic-control
version0.3.2
sourcesrc
created_at2022-04-16 21:06:50.846171
updated_at2022-05-19 10:21:18.339201
descriptionA video game for programmers about air traffic control
homepagehttps://auto-traffic-control.com
repositoryhttps://github.com/jdno/auto-traffic-control
max_upload_size
id569145
size9,974
Jan David (jdno)

documentation

README

🛬 Auto Traffic Control

GitHub Workflow Status Version License

Homepage | Documentation | Community

Auto Traffic Control is a video game played by programming. The player's task is to create a program that can safely manage the airspace above two airports.

The game is designed to provide an open-ended sandbox that players can use to freely practice programming. The game provides a language-agnostic gRPC API, giving players free choice of programming language or paradigm.

This crate contains the auto-generated Rust SDK for the game's gRPC API.

Usage

First, add auto-traffic-control as a new dependency to your Cargo.toml.

[dependencies]
auto-traffic-control = "0.3.2"

You also need to add tonic, the Rust implementation of gRPC, and tokio, the async runtime, as a dependency.

Then, create a service client and send a request. Check out the documentation to learn about the different services and their endpoints.

The following example queries the version of the game through the AtcService.

use auto_traffic_control::v1::atc_service_client::AtcServiceClient;
use auto_traffic_control::v1::GetVersionRequest;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut atc_service = AtcServiceClient::connect("http://localhost:4747").await?;

    let response = atc_service.get_version(GetVersionRequest {}).await?;
    let version_field = response.into_inner().version;

    if let Some(version) = version_field {
        let mut version_string = format!("{}.{}.{}", version.major, version.minor, version.patch);

        if !version.pre.is_empty() {
            version_string.push('-');
            version_string.push_str(&version.pre);
        }

        println!("Auto Traffic Control is running version '{version_string}'");
    } else {
        println!("Requesting the version returned an empty response.");
    }

    Ok(())
}

License

Licensed under either of

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.

Commit count: 288

cargo fmt