bigquery_functions/
types.rs

1use crate::json_types;
2use bigquery_functions_types_macros::enum_category;
3use serde::{Deserialize, Serialize};
4
5enum_category!();
6
7#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub struct Function {
9    pub name: String,
10    pub arguments: Vec<Argument>,
11    pub category: Category,
12    pub description_markdown: String,
13}
14
15impl Function {
16    pub fn new(
17        name: String,
18        arguments: Vec<Argument>,
19        category: Category,
20        description_markdown: String,
21    ) -> Self {
22        Function {
23            name,
24            arguments,
25            category,
26            description_markdown,
27        }
28    }
29}
30
31#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
32pub struct Argument {
33    pub name: Option<String>,
34    pub supported_argument_type: String,
35}
36
37impl Argument {
38    pub fn new(name: Option<String>, supported_argument_type: String) -> Self {
39        Argument {
40            name,
41            supported_argument_type,
42        }
43    }
44
45    pub fn from_json_function_argument(json_function_argument: &json_types::Argument) -> Self {
46        Self {
47            name: json_function_argument.name.clone(),
48            supported_argument_type: json_function_argument.supported_argument_type.clone(),
49        }
50    }
51}