use super::*;
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct PkgInstallerLayer {
#[serde(flatten)]
pub common: CommonInstallerLayer,
pub identifier: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub install_location: Option<String>,
}
#[derive(Debug, Default, Clone)]
pub struct PkgInstallerConfig {
pub common: CommonInstallerConfig,
pub identifier: Option<String>,
pub install_location: String,
}
impl PkgInstallerConfig {
pub fn defaults_for_package(
_workspaces: &WorkspaceGraph,
_pkg_idx: PackageIdx,
common: &CommonInstallerConfig,
) -> Self {
Self {
common: common.clone(),
identifier: None,
install_location: "/usr/local".to_owned(),
}
}
}
impl ApplyLayer for PkgInstallerConfig {
type Layer = PkgInstallerLayer;
fn apply_layer(
&mut self,
Self::Layer {
common,
identifier,
install_location,
}: Self::Layer,
) {
self.common.apply_layer(common);
self.identifier.apply_opt(identifier);
self.install_location.apply_val(install_location);
}
}
impl ApplyLayer for PkgInstallerLayer {
type Layer = PkgInstallerLayer;
fn apply_layer(
&mut self,
Self::Layer {
common,
identifier,
install_location,
}: Self::Layer,
) {
self.common.apply_layer(common);
self.identifier.apply_opt(identifier);
self.install_location.apply_opt(install_location);
}
}
impl std::ops::Deref for PkgInstallerConfig {
type Target = CommonInstallerConfig;
fn deref(&self) -> &Self::Target {
&self.common
}
}