fkl_parser/mir/binding/
source_set.rs1use serde::Deserialize;
2use serde::Serialize;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
5pub struct SourceSets {
6 pub name: String,
7 pub source_sets: Vec<SourceSet>,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
11pub struct SourceSet {
12 pub name: String,
13 pub description: String,
14 pub parser: String,
15 pub extension: String,
16 pub src_dirs: Vec<String>,
17 pub source_set_type: SourceSetType,
18}
19
20impl SourceSet {
21 pub fn new(name: &str) -> Self {
22 SourceSet {
23 name: name.to_string(),
24 parser: "".to_string(),
25 description: "".to_string(),
26 extension: "".to_string(),
27 src_dirs: vec![],
28 source_set_type: SourceSetType::default(),
29 }
30 }
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
34pub enum SourceSetType {
35 None,
36 StructUml,
37 StructJsonSchema,
38 StructProtobuf,
39 StructAvro,
40 OpenApi,
41 Csv,
42}
43
44impl Default for SourceSetType {
45 fn default() -> Self {
46 SourceSetType::None
47 }
48}
49
50impl SourceSetType {
51 pub fn from_str(s: &str) -> Self {
52 match s.to_lowercase().as_str() {
53 "uml" => SourceSetType::StructUml,
54 "puml" => SourceSetType::StructUml,
55 "json_schema" => SourceSetType::StructJsonSchema,
56 "jsonschema" => SourceSetType::StructJsonSchema,
57 "protobuf" => SourceSetType::StructProtobuf,
58 "avro" => SourceSetType::StructAvro,
59 "open_api" => SourceSetType::OpenApi,
60 "openapi" => SourceSetType::OpenApi,
61 "csv" => SourceSetType::Csv,
62 _ => SourceSetType::None,
63 }
64 }
65}