lux_lib/lua_rockspec/
deploy.rs1use std::convert::Infallible;
2
3use serde::Deserialize;
4
5use crate::lua_rockspec::{DisplayAsLuaKV, DisplayLuaKV, DisplayLuaValue};
6
7use super::{PartialOverride, PerPlatform, PlatformOverridable};
8
9#[derive(Clone, Debug, PartialEq, Deserialize)]
13pub struct DeploySpec {
14 #[serde(default = "default_wrap_bin_scripts")]
18 pub wrap_bin_scripts: bool,
19}
20
21impl Default for DeploySpec {
22 fn default() -> Self {
23 Self {
24 wrap_bin_scripts: true,
25 }
26 }
27}
28
29impl PartialOverride for DeploySpec {
30 type Err = Infallible;
31
32 fn apply_overrides(&self, override_spec: &Self) -> Result<Self, Self::Err> {
33 Ok(Self {
34 wrap_bin_scripts: override_spec.wrap_bin_scripts,
35 })
36 }
37}
38
39impl PlatformOverridable for DeploySpec {
40 type Err = Infallible;
41
42 fn on_nil<T>() -> Result<PerPlatform<T>, <Self as PlatformOverridable>::Err>
43 where
44 T: PlatformOverridable,
45 T: Default,
46 {
47 Ok(PerPlatform::default())
48 }
49}
50
51impl DisplayAsLuaKV for DeploySpec {
52 fn display_lua(&self) -> DisplayLuaKV {
53 DisplayLuaKV {
54 key: "deploy".to_string(),
55 value: DisplayLuaValue::Table(vec![DisplayLuaKV {
56 key: "wrap_bin_scripts".to_string(),
57 value: DisplayLuaValue::Boolean(self.wrap_bin_scripts),
58 }]),
59 }
60 }
61}
62
63fn default_wrap_bin_scripts() -> bool {
64 true
65}