lux_lib/lua_rockspec/
deploy.rs

1use std::convert::Infallible;
2
3use serde::Deserialize;
4
5use super::{PartialOverride, PerPlatform, PlatformOverridable};
6
7/// An undocumented part of the rockspec format.
8///
9/// Specifies additional install options
10#[derive(Clone, Debug, PartialEq, Deserialize)]
11pub struct DeploySpec {
12    /// Whether to wrap installed Lua bin scripts to be executed with
13    /// the detected or configured Lua installation.
14    /// Defaults to `true`.
15    /// This only affects lua bin scripts that are declared in the rockspec.
16    #[serde(default = "default_wrap_bin_scripts")]
17    pub wrap_bin_scripts: bool,
18}
19
20impl Default for DeploySpec {
21    fn default() -> Self {
22        Self {
23            wrap_bin_scripts: true,
24        }
25    }
26}
27
28impl PartialOverride for DeploySpec {
29    type Err = Infallible;
30
31    fn apply_overrides(&self, override_spec: &Self) -> Result<Self, Self::Err> {
32        Ok(Self {
33            wrap_bin_scripts: override_spec.wrap_bin_scripts,
34        })
35    }
36}
37
38impl PlatformOverridable for DeploySpec {
39    type Err = Infallible;
40
41    fn on_nil<T>() -> Result<PerPlatform<T>, <Self as PlatformOverridable>::Err>
42    where
43        T: PlatformOverridable,
44        T: Default,
45    {
46        Ok(PerPlatform::default())
47    }
48}
49
50fn default_wrap_bin_scripts() -> bool {
51    true
52}