pub mod error;
use error::BuiltinError;
use super::{trig_mode::TrigMode, value::Value};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BuiltinParam {
pub name: &'static str,
pub kind: ParamKind,
pub typename: Option<&'static str>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ParamKind {
Required,
Optional,
}
pub trait Builtin: std::fmt::Debug + Send + Sync {
fn name(&self) -> &'static str;
fn sig(&self) -> &'static [BuiltinParam];
fn sig_str(&self) -> &'static str;
fn eval(&self, trig_mode: TrigMode, args: Vec<Value>) -> Result<Value, BuiltinError>;
}
impl Builtin for &'static dyn Builtin {
fn name(&self) -> &'static str {
(**self).name()
}
fn sig(&self) -> &'static [BuiltinParam] {
(**self).sig()
}
fn sig_str(&self) -> &'static str {
(**self).sig_str()
}
fn eval(&self, trig_mode: TrigMode, args: Vec<Value>) -> Result<Value, BuiltinError> {
(**self).eval(trig_mode, args)
}
}