Crates.io | piston_rs |
lib.rs | piston_rs |
version | 0.4.3 |
source | src |
created_at | 2021-11-27 10:47:54.94106 |
updated_at | 2022-06-30 16:05:18.040265 |
description | An async wrapper for the Piston code execution engine. |
homepage | https://github.com/Jonxslays/piston_rs |
repository | https://github.com/Jonxslays/piston_rs |
max_upload_size | |
id | 488354 |
size | 48,021 |
An async wrapper for the Piston code execution engine.
piston_rs aims to make interacting with Piston fun and easy. Your main
tools are the Client
and Executor
structs.
The Executor
is constructed containing the source code and other metadata about the code you are
running. This is then sent to Piston via the
Client
.
piston_rs requires Rust version 1.46.0 or greater.
For more details, check out the documentation!
# Cargo.toml
[dependencies]
piston_rs = "^0.4"
// main.rs
#[tokio::main]
async fn main() {
let client = piston_rs::Client::new();
let executor = piston_rs::Executor::new()
.set_language("rust")
.set_version("*")
.add_file(
piston_rs::File::default()
.set_name("main.rs")
.set_content("fn main() { println!(\"42\"); }")
);
match client.execute(&executor).await {
Ok(response) => {
println!("Language: {}", response.language);
println!("Version: {}", response.version);
if let Some(c) = response.compile {
println!("Compilation: {}", c.output);
}
println!("Output: {}", response.run.output);
}
Err(e) => {
println!("Something went wrong contacting Piston.");
println!("{}", e);
}
}
}
piston_rs is licensed under the MIT License.