Skip to main content

mk_lib/schema/
include.rs

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