1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use std::path::Path;
use std::str::FromStr;
use std::{fs::File, io::Read};
mod json_types;
pub mod types;
pub fn get_bigquery_function_names() -> Vec<String> {
let path = Path::new(env!("CARGO_MANIFEST_DIR"));
let mut f = File::open(path.join("output/function_names.json")).unwrap();
let mut contents = String::new();
f.read_to_string(&mut contents).unwrap();
let function_names: Vec<String> = serde_json::from_str(&contents).unwrap();
return function_names;
}
pub fn get_bigquery_function_categories() -> Vec<String> {
let path = Path::new(env!("CARGO_MANIFEST_DIR"));
let mut f = File::open(path.join("output/categories.json")).unwrap();
let mut contents = String::new();
f.read_to_string(&mut contents).unwrap();
let categories: Vec<String> = serde_json::from_str(&contents).unwrap();
return categories;
}
pub fn get_bigquery_functions() -> Vec<types::Function> {
let path = Path::new(env!("CARGO_MANIFEST_DIR"));
let mut f = File::open(path.join("output/functions.json")).unwrap();
let mut contents = String::new();
f.read_to_string(&mut contents).unwrap();
let functions: Vec<json_types::Function> = serde_json::from_str(&contents).unwrap();
let converted_functions = functions
.into_iter()
.map(|function| {
types::Function::new(
function.name,
function
.arguments
.into_iter()
.map(|argument| {
types::Argument::new(argument.name, argument.supported_argument_type)
})
.collect(),
types::Category::from_str(&function.category)
.unwrap_or(types::Category::NoCategory),
function.return_type,
function.description,
)
})
.collect();
return converted_functions;
}