-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
scriptingEmbedded scripting for PantheonEmbedded scripting for Pantheon
Description
The following modules need to be implemented before we can consider our standard library to be usable.
("..." means the signature can be resolved later, or is still up in the air)
-
fs-
read(file_path: &str) -> Result<String> -
read_lines(file_path: &str) -> Result<Vec<String>> -
write(file_path: &str, contents: &str) -> Result<()> -
write_lines(file_path: &str, lines: Vec<&str>) -> Result<()> -
append(file_path: &str, addition: &str) -> Result<()> -
append_lines(file_path: &str, addition_lines: Vec<&str>) -> Result<()> -
remove(path: &str) -> Result<()> -
create(file_path: &str) -> Result<()> -
mkdir(dir_path: &str) -> Result<()> -
exists(path: &str) -> bool -
is_file(path: &str) -> bool -
is_dir(path: &str) -> bool -
list(dir_path: &str) -> Result<Vec<String>>
-
-
http-
post(url: &str, ......?) -> Result<String> -
get(url: &str, params: Vec<(&str, &str)>, headers: Option<Vec<(&str, &str)>> -> Result<String> -
put(...) -> Result<...> -
head(...) -> Result<...> -
delete(...) -> Result<...> -
download(url: &str, output_path: &str) -> Result<()> -
upload(....) -> Result<...>
-
-
sys-
os_family() -> String -
os_name() -> String -
username() -> String -
hostname() -> String -
is_admin() -> bool -
reboot() -> Result<()> -
shutdown() -> Result<()> -
uptime -> Result<u64> [ ]hermes_dir() -> String-
cpu_architecture() -> Result<String> -
is_windows() -> bool -
is_linux() -> bool -
is_macos() -> bool -
is_bsd() -> bool
-
-
proc-
list() -> Result<Vec<(String, u32)>> -
kill(pid: u32) -> Result<()> -
start(command: &str, args: &[&str]) -> Result<u32> -
current_pid() -> u32
-
-
time-
sleep(ms: u64) -
current() -> u64
-
-
net-
local_ip() -> Result<String> -
public_ip() -> Result<String>
-
-
crypto-
sha256(input: &str) -> String -
sha1(input: &str) -> String -
md5(input: &str) -> String -
b64_decode(input: &str) -> Result<String> -
b64_encode(input: &str) -> String
-
-
env-
get(key: &str) -> Option<String> -
set(key: &str, value: &str) -
remove(key: &str) -
list() -> Vec<(String, String)>
-
Implementation example in Rust:
#[export_module]
mod module_name {
// Methods that return Result<T, Box<EvalAltResult>> can throw exceptions
// Which is to say, they are failable
#[rhai_fn(return_raw)]
pub fn divide(x: i64, y: i64) -> Result<i64, Box<EvalAltResult>> {
if y == 0 {
Err("Division by zero!".into())
} else {
Ok(x / y)
}
}
// This method is infailable, so we don't have to worry about
// returning a Result<T>
//
// We also don't have to annotate it with: #[rhai_fn(return_raw)]
pub fn get_name() -> String {
return String::from("agent name");
}
}Evaluation example in Rhai:
fn run() {
try {
// This will fail as we are dividing by zero
let result = module_name::divide(10, 0);
}
catch (error) {
// "Division by zero!"
print(error)
}
// Infailable, so we don't have to worry about try..catch
let name = get_name();
}Metadata
Metadata
Assignees
Labels
scriptingEmbedded scripting for PantheonEmbedded scripting for Pantheon