sea_orm_dbml/compiler/
config.rs

1use std::ffi::OsString;
2
3#[derive(Debug)]
4pub enum EnumType {
5  String(Option<u32>),
6  Integer,
7}
8
9#[derive(Debug)]
10/// Configuration options for the code generation.
11pub struct Config {
12  /// Input file path.
13  pub in_path: OsString,
14  /// Output file path (optional). The default output path is `OUT_DIR`.
15  pub out_path: OsString,
16  /// Database entity target.
17  pub target: Target,
18  /// Enum type for storing a value. It can be either `String` and `Interger`.
19  /// The `String` type requires to specify the length of characters that will be stored.
20  pub enum_type: EnumType,
21  /// Enable native enum for the database.
22  pub is_native_enum: bool
23}
24
25impl Default for Config {
26  fn default() -> Self {
27    Self {
28      in_path: OsString::from(""),
29      out_path: OsString::from(""),
30      target: Target::Postgres,
31      enum_type: EnumType::String(None),
32      is_native_enum: true
33    }
34  }
35}
36
37impl Config {
38  pub fn validate(&self) -> Option<&str> {
39    if self.in_path.is_empty() {
40      Some("in_path is not set")
41    } else if self.out_path.is_empty() {
42      Some("out_path is not set")
43    } else {
44      None
45    }
46  }
47}
48
49/// Database entity target.
50#[derive(Debug, PartialEq, Clone)]
51pub enum Target {
52  // MySQL,
53  Postgres,
54  // Sqlite
55}
56