1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! playground-api: Rust Playground API Client
//! ===========================================
//!
//! `playground-api` is a Rust crate designed to simplify interaction with the
//! Rust Playground API. It provides both an asynchronous client by default and
//! an optional blocking client when compiled with the `blocking` feature.
//!
//! ## Features
//!
//! - **Async client** (default): uses `reqwest::Client` under the hood to send
//! non-blocking HTTP requests.
//! - **Blocking client** (`blocking` feature): enables `reqwest::blocking::Client`
//! for environments where async is not desired or available.
//! - **Poise support** (`poise-bot` feature): makes all enums derive the
//! `poise::ChoiceParameter` macro.
//!
//! ## Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! playground-api = "0.3.0" # or latest
//! ```
//!
//! To enable the blocking client as well:
//!
//! ```toml
//! [dependencies]
//! playground-api = { version = "0.3.0", features = ["blocking"] }
//! ```
//!
//! ## Usage
//!
//! ### Async (default)
//!
//! ```rust,ignore
//! use playground_api::{Client, endpoints::{ExecuteRequest, Channel, Mode, Edition, CrateType}, Error};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Error> {
//! // Uses the official https://play.rust-lang.org/ by default
//! let client = Client::default();
//!
//! let req = ExecuteRequest::new(
//! Channel::Stable,
//! Mode::Release,
//! Edition::Edition2021,
//! CrateType::Binary,
//! false,
//! false,
//! r#"println!("Hello, async world!");"#.into(),
//! );
//!
//! let res = client.execute(&req).await?;
//! println!("{}", res.stdout);
//! Ok(())
//! }
//! ```
//!
//! ### Blocking (with `blocking` feature)
//!
//! ```rust,ignore
//! use playground_api::{blocking::Client, endpoints::{ExecuteRequest, Channel, Mode, Edition, CrateType}, Error};
//!
//! fn main() -> Result<(), Error> {
//! // Compile your crate with `--features blocking`
//! let client = Client::default();
//!
//! let req = ExecuteRequest::new(
//! Channel::Stable,
//! Mode::Release,
//! Edition::Edition2021,
//! CrateType::Binary,
//! false,
//! false,
//! r#"println!("Hello, blocking world!");"#.into(),
//! );
//!
//! let res = client.execute(&req)?;
//! println!("{}", res.stdout);
//! Ok(())
//! }
//! ```
//!
//! ## License
//!
//! This project is licensed under the MIT License.
pub use Client;
pub use Error;