2023-11-30 02:09:55 -05:00
|
|
|
use crate::{Map, Result, Value};
|
2023-11-28 17:54:17 -05:00
|
|
|
|
2023-11-30 10:00:40 -05:00
|
|
|
mod assert;
|
2023-11-30 10:10:03 -05:00
|
|
|
mod data_formats;
|
2023-11-28 17:54:17 -05:00
|
|
|
mod fs;
|
|
|
|
mod output;
|
2023-11-30 11:05:09 -05:00
|
|
|
mod random;
|
2023-11-30 02:09:55 -05:00
|
|
|
mod r#type;
|
2023-11-28 17:54:17 -05:00
|
|
|
|
2023-11-30 11:07:52 -05:00
|
|
|
pub const BUILT_IN_FUNCTIONS: [&dyn BuiltInFunction; 13] = [
|
2023-11-30 10:00:40 -05:00
|
|
|
&assert::Assert,
|
|
|
|
&assert::AssertEqual,
|
2023-11-30 10:10:03 -05:00
|
|
|
&data_formats::FromJson,
|
|
|
|
&data_formats::ToJson,
|
2023-11-30 02:09:55 -05:00
|
|
|
&fs::Read,
|
|
|
|
&fs::Write,
|
|
|
|
&fs::Append,
|
|
|
|
&output::Output,
|
2023-11-30 11:05:09 -05:00
|
|
|
&random::Random,
|
2023-11-30 11:07:52 -05:00
|
|
|
&random::RandomBoolean,
|
|
|
|
&random::RandomFloat,
|
2023-11-30 11:05:09 -05:00
|
|
|
&random::RandomInteger,
|
2023-11-30 02:09:55 -05:00
|
|
|
&r#type::Type,
|
|
|
|
];
|
2023-11-28 17:54:17 -05:00
|
|
|
|
|
|
|
pub trait BuiltInFunction {
|
|
|
|
fn name(&self) -> &'static str;
|
2023-11-30 02:09:55 -05:00
|
|
|
fn run(&self, arguments: &[Value], context: &Map) -> Result<Value>;
|
2023-11-28 17:54:17 -05:00
|
|
|
}
|