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

A client used to send requests to Piston.

A response returned by Piston when executing code.

The result of code execution returned by Piston.

An object containing information about the code being executed.

A file that contains source code to be executed.

The error that is returned when loading from a File on disk fails for any reason.

A runtime available to be used by Piston.