use std::borrow::Cow;
use super::{DataType, DeprecatedType};
#[derive(Debug, Clone)]
pub struct Function {
pub(crate) asyncness: bool,
pub(crate) name: Cow<'static, str>,
pub(crate) args: Vec<(Cow<'static, str>, DataType)>,
pub(crate) result: Option<FunctionResultVariant>,
pub(crate) docs: Cow<'static, str>,
pub(crate) deprecated: Option<DeprecatedType>,
}
#[derive(Debug, Clone)]
pub enum FunctionResultVariant {
Value(DataType),
Result(DataType, DataType),
}
impl Function {
pub fn asyncness(&self) -> bool {
self.asyncness
}
pub fn name(&self) -> &Cow<'static, str> {
&self.name
}
pub fn args(&self) -> impl Iterator<Item = &(Cow<'static, str>, DataType)> {
self.args.iter()
}
pub fn result(&self) -> Option<&FunctionResultVariant> {
self.result.as_ref()
}
pub fn docs(&self) -> &Cow<'static, str> {
&self.docs
}
pub fn deprecated(&self) -> Option<&DeprecatedType> {
self.deprecated.as_ref()
}
}