oneline_template/function_executor/
function_schema.rs

1use crate::function_executor::function_argument::FunctionArgument;
2
3/// Contains information about function: function name, argument types.
4#[derive(Debug)]
5pub struct FunctionSchema {
6    function_name: String,
7    arguments: Vec<FunctionArgument>,
8}
9
10impl FunctionSchema {
11    /// Creates function name.
12    ///
13    /// # Panics
14    ///
15    /// Panics if `function_name` is empty.
16    pub fn new(
17        function_name: impl Into<String>,
18    ) -> FunctionSchema {
19        let function_name = function_name.into();
20        if function_name.is_empty() {
21            panic!("Passed function name is empty");
22        }
23        return FunctionSchema {
24            function_name,
25            arguments: Vec::new(),
26        }
27    }
28
29    /// Adds function argument.
30    pub fn with_argument(mut self, argument: FunctionArgument) -> Self {
31        self.arguments.push(argument);
32        return self;
33    }
34
35    /// Returns function name.
36    pub fn get_function_name(&self) -> &String {
37        return &self.function_name;
38    }
39
40
41    /// Returns list of arguments.
42    pub fn get_arguments(&self) -> &[FunctionArgument] {
43        return &self.arguments;
44    }
45}