Skip to content

Commit

Permalink
refactor: mark types as non_exhaustive
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Nov 30, 2023
1 parent 7c8e3b7 commit 0d12f48
Show file tree
Hide file tree
Showing 14 changed files with 1,307 additions and 398 deletions.
5 changes: 5 additions & 0 deletions .changes/non-exhuastive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-packager": minor
---

Mark most of the types as `non_exhaustive` to allow adding more field later on without having to break downstream users use the newly added helper methods on these types to modify the corresponding fields in-place.
12 changes: 6 additions & 6 deletions bindings/updater/nodejs/src/from_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ impl From<cargo_packager_updater::WindowsUpdateInstallMode> for WindowsUpdateIns
impl From<cargo_packager_updater::UpdaterWindowsConfig> for UpdaterWindowsOptions {
fn from(value: cargo_packager_updater::UpdaterWindowsConfig) -> Self {
Self {
installer_args: Some(value.installer_args),
install_mode: Some(value.install_mode.into()),
installer_args: value.installer_args,
install_mode: value.install_mode.map(Into::into),
}
}
}
impl From<UpdaterWindowsOptions> for cargo_packager_updater::UpdaterWindowsConfig {
fn from(value: UpdaterWindowsOptions) -> Self {
Self {
installer_args: value.installer_args.unwrap_or_default(),
install_mode: value.install_mode.map(Into::into).unwrap_or_default(),
installer_args: value.installer_args,
install_mode: value.install_mode.map(Into::into),
}
}
}
Expand All @@ -46,7 +46,7 @@ impl From<Options> for cargo_packager_updater::Config {
.filter_map(|e| e.parse().ok())
.collect(),
pubkey: value.pubkey,
windows: value.windows.map(Into::into).unwrap_or_default(),
windows: value.windows.map(Into::into),
}
}
}
Expand Down Expand Up @@ -99,7 +99,7 @@ impl From<cargo_packager_updater::Update> for Update {
})
.collect(),
format: value.format.into(),
windows: value.config.windows.into(),
windows: value.config.windows.map(Into::into),
}
}
}
4 changes: 2 additions & 2 deletions bindings/updater/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub struct Update {
/// Update format
pub format: UpdateFormat,
/// The Windows options for the updater.
pub windows: UpdaterWindowsOptions,
pub windows: Option<UpdaterWindowsOptions>,
/// Update description
pub body: Option<String>,
/// Update publish date
Expand All @@ -138,7 +138,7 @@ impl Update {
Ok(cargo_packager_updater::Update {
config: cargo_packager_updater::Config {
pubkey: self.pubkey.clone(),
windows: self.windows.clone().into(),
windows: self.windows.clone().map(Into::into),
..Default::default()
},
body: self.body.clone(),
Expand Down
Loading

0 comments on commit 0d12f48

Please sign in to comment.