Skip to main content

mk_lib/schema/
include.rs

1use serde::Deserialize;
2
3#[derive(Debug, Deserialize)]
4pub struct IncludeArgs {
5  pub name: String,
6
7  #[serde(default)]
8  pub overwrite: bool,
9}
10
11#[derive(Debug, Deserialize)]
12#[serde(untagged)]
13pub enum Include {
14  String(String),
15  Include(Box<IncludeArgs>),
16}
17
18impl Include {
19  pub fn name(&self) -> &str {
20    match self {
21      Include::String(name) => name,
22      Include::Include(args) => &args.name,
23    }
24  }
25
26  pub fn overwrite(&self) -> bool {
27    match self {
28      Include::String(_) => false,
29      Include::Include(args) => args.overwrite,
30    }
31  }
32}