Expand description
piston_rs
- An async wrapper for the
Piston code execution
engine.
Aiming to make interacting with Piston fun and easy.
§Getting started
Check out the Client
and Executor
documentation.
§Make requests to Piston
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);
}
}
Structs§
- Client
- A client used to send requests to Piston.
- Exec
Response - A response returned by Piston when executing code.
- Exec
Result - The result of code execution returned by Piston.
- Executor
- An object containing information about the code being executed.
- File
- A file that contains source code to be executed.
- Load
Error - The error that is returned when loading from a
File
on disk fails for any reason. - Runtime
- A runtime available to be used by Piston.