Skip to content

Commit

Permalink
feat: some fixes for developer xperience
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioRibera committed Aug 21, 2024
1 parent d6368cd commit eaec02c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use crate::{
/// `POST` /api/v2/execute This endpoint requests execution of some arbitrary code.
///
/// language (required) The language to use for execution, must be a string and must be installed.
/// version (required) The version of the language to use for execution, must be a string containing a SemVer selector for the version or the specific version number to use.
/// version (required) The version of the language to use for execution, must be a string containing a `SemVer` selector for the version or the specific version number to use.
/// files (required) An array of files containing code or other data that should be used for execution. The first file in this array is considered the main file.
/// files[].name (optional) The name of the file to upload, must be a string containing no path or left out.
/// files[].content (required) The content of the files to upload, must be a string containing text to write.
/// files[].encoding (optional) The encoding scheme used for the file content. One of base64, hex or utf8. Defaults to utf8.
/// stdin (optional) The text to pass as stdin to the program. Must be a string or left out. Defaults to blank string.
/// args (optional) The arguments to pass to the program. Must be an array or left out. Defaults to [].
/// compile_timeout (optional) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to 10000 (10 seconds).
/// run_timeout (optional) The maximum time allowed for the run stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to 3000 (3 seconds).
/// compile_memory_limit (optional) The maximum amount of memory the compile stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit)
/// run_memory_limit (optional) The maximum amount of memory the run stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit)#[derive(Serialize)]
/// `compile_timeout` (optional) The maximum time allowed for the compile stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to 10000 (10 seconds).
/// `run_timeout` (optional) The maximum time allowed for the run stage to finish before bailing out in milliseconds. Must be a number or left out. Defaults to 3000 (3 seconds).
/// `compile_memory_limit` (optional) The maximum amount of memory the compile stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit)
/// `run_memory_limit` (optional) The maximum amount of memory the run stage is allowed to use in bytes. Must be a number or left out. Defaults to -1 (no limit)#[derive(Serialize)]
#[derive(Clone, Serialize)]
struct Data {
language: String,
Expand Down Expand Up @@ -98,8 +98,8 @@ impl Client {
let runtime_url = build_url(url.as_ref(), self.api_version, RUNTIMES_PATH);
let exec_url = build_url("https://emkc.org", self.api_version, EXECUTE_PATH);
Self {
runtime_url,
exec_url,
runtime_url,
..self
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ pub struct Response {
}

impl Response {
#[must_use]
pub fn language(&self) -> &str {
self.language.as_ref()
}

#[must_use]
pub fn version(&self) -> &str {
self.version.as_ref()
}

#[must_use]
pub fn data(&self) -> &RunData {
&self.run
}
Expand All @@ -42,6 +45,7 @@ pub struct ErrorResponse {
}

impl ErrorResponse {
#[must_use]
pub fn message(&self) -> &str {
self.message.as_ref()
}
Expand All @@ -56,18 +60,22 @@ pub struct RunData {
}

impl RunData {
#[must_use]
pub fn stdout(&self) -> &str {
self.stdout.as_ref()
}

#[must_use]
pub fn output(&self) -> &str {
self.output.as_ref()
}

#[must_use]
pub fn code(&self) -> u8 {
self.code
}

#[must_use]
pub fn signal(&self) -> Option<&str> {
self.signal.as_deref()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ mod client_tests {
)
.await;

assert!(client.is_ok())
assert!(client.is_ok());
}
}

0 comments on commit eaec02c

Please sign in to comment.