teo_runtime/struct/function/
static_function.rs

1use std::sync::Arc;
2use educe::Educe;
3use serde::Serialize;
4use crate::arguments::Arguments;
5use teo_result::Result;
6use crate::value::Value;
7
8#[derive(Educe, Serialize, Clone)]
9#[educe(Debug)]
10pub struct Definition {
11    pub path: Vec<String>,
12    #[educe(Debug(ignore))] #[serde(skip)]
13    pub body: Arc<dyn StaticFunction>,
14}
15
16pub trait StaticFunction: Send + Sync {
17    fn call(&self, arguments: Arguments) -> Result<Value>;
18}
19
20impl<F> StaticFunction for F where
21    F: Fn(Arguments) -> Result<Value> + Send + Sync {
22    fn call(&self, arguments: Arguments) -> Result<Value> {
23        self(arguments)
24    }
25}
26