{"id":18761443,"url":"https://github.com/rustlanges/pistones","last_synced_at":"2025-04-13T03:31:26.902Z","repository":{"id":251687080,"uuid":"838136477","full_name":"RustLangES/pistones","owner":"RustLangES","description":"Lib a high performance general purpose code execution engine","archived":false,"fork":false,"pushed_at":"2024-08-28T02:56:20.000Z","size":65,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-11T13:36:50.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://crates.io/crates/pistones","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RustLangES.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-05T02:49:48.000Z","updated_at":"2024-09-06T03:48:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"17bba345-e3f6-4fbd-9457-c30759a96ed5","html_url":"https://github.com/RustLangES/pistones","commit_stats":null,"previous_names":["rustlanges/pistones"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RustLangES%2Fpistones","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RustLangES%2Fpistones/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RustLangES%2Fpistones/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RustLangES%2Fpistones/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RustLangES","download_url":"https://codeload.github.com/RustLangES/pistones/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248659645,"owners_count":21141152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T18:16:06.426Z","updated_at":"2025-04-13T03:31:26.639Z","avatar_url":"https://github.com/RustLangES.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚂 pistones\n\nUnofficial API Client wrapper from [engineer-man/piston](https://github.com/engineer-man/piston?tab=readme-ov-file#Public-API)\n\n### Functionality\n\nThe Piston client provides functionalities to:\n\n* **Create a Piston client:** Establish a connection with the Piston execution environment.\n* **Configure the client:**\n    * Set the API version.\n    * Set the base URL for the Piston API.\n    * Enable or disable language caching.\n    * Define a custom `reqwest` client for HTTP requests.\n* **Language Management:**\n    * Fetch a list of supported languages and their versions.\n    * Get the version for a specific language.\n* **Code Execution:**\n    * Execute Piston code provided as strings or files.\n    * Specify the language and version for code execution.\n\n### Usage\n\nThe library utilizes an asynchronous programming model. Here's a basic example demonstrating how to run a Piston script:\n\n```rust\nuse piston_client::Client;\n\n#[tokio::main]\nfn main() -\u003e Result\u003c(), piston_client::Error\u003e\u003e {\n    let mut client = Client::new()?;\n\n    // Get the Rust language version\n    let rust_version = client.lang_version(\"rust\").await?;\n    println!(\"Rust version: {}\", rust_version);\n\n    // Define the code to run\n    let code = r#\"\n        fn main() {\n            println!(\"Hello, Piston!\");\n        }\n    \"#;\n\n    // Run the code\n    let response = client.run(\"rust\", code.to_string()).await?;\n\n    // Process the response\n    println!(\"Response: {:?}\", response);\n\n    Ok(())\n}\n```\n\n### Client Configuration\n\n* **API Version:** By default, the client uses the default API version. You can change this using the `api_version` method.\n* **Base URL:** The base URL for the Piston API defaults to `https://emkc.org`. You can override this with the `base_url` method.\n* **Language Caching:** Language information is fetched from the Piston API by default and cached for subsequent use. You can disable caching with the `disable_cache` method.\n* **Custom Client:** The library utilizes `reqwest` for making HTTP requests. You can provide your own `reqwest::Client` instance using the `custom_client` method.\n\n### Client Methods\n\n* **new:** Creates a new Piston client instance.\n* **api_version:** Sets the API version to be used by the client.\n* **base_url:** Sets the base URL for the Piston API.\n* **disable_cache:** Disables language information caching.\n* **user_agent:** Sets a custom user agent for HTTP requests.\n* **custom_client:** Sets a custom `reqwest` client for HTTP requests.\n* **refresh_cache:** Updates the cached language information.\n* **get_languages:** Retrieves a list of supported languages and their versions.\n* **lang_version:** Gets the version for a specific language.\n* **exec:** Executes Piston code provided as files.\n* **run_files:** Executes Piston code provided through an iterator of `FileData` structs.\n* **run_with_version:** Executes Piston code with a specified language version and content string.\n* **run:** Executes Piston code with a retrieved language version and content string.\n\n### Data Structures\n\n* **Language:** Represents a supported language with its name, aliases, and version.\n* **FileData:** Represents a file to be included in the code execution. It has optional `name` and required `content` fields.\n* **Error:** Represents errors that can occur during library usage.\n* **ApiResponse:** Represents the response received from the Piston API after code execution. It can be either a successful execution result or an error message.\n\n### Contributing\n\nFeel free to contribute to this library by opening pull requests on the relevant Github repository. Make sure to follow the project's contribution guidelines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustlanges%2Fpistones","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustlanges%2Fpistones","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustlanges%2Fpistones/lists"}