Skip to content

Commit

Permalink
fix(cfg/manifest): trait issues with BootstrapOption
Browse files Browse the repository at this point in the history
  • Loading branch information
madonuko committed Jul 18, 2024
1 parent 7f18095 commit 0a68a40
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ thiserror = "1.0.61"
ensan-proc-macro = "0.1.0"
passwd-rs = "0.2.0"
serde_json = "1.0.120"
dyn-clone = "1.0.17"

[lints.clippy]
cargo = "warn"
Expand Down
18 changes: 17 additions & 1 deletion src/cfg/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,25 @@ pub enum BuilderType {
Dnf,
}

pub trait BootstrapOption: Debug {
pub trait BootstrapOption: Debug + dyn_clone::DynClone {
fn bootstrap_system(&self) -> color_eyre::Result<()>;
}

mod bootstrap_option_serde {
use super::*;

pub fn serialize<'se, S>(
bootstrap_option: &Box<dyn BootstrapOption>, serializer: S,

Check failure on line 36 in src/cfg/manifest.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused variable: `bootstrap_option`

Check warning on line 36 in src/cfg/manifest.rs

View workflow job for this annotation

GitHub Actions / unit-test

unused variable: `bootstrap_option`

Check warning on line 36 in src/cfg/manifest.rs

View workflow job for this annotation

GitHub Actions / unit-test

unused variable: `serializer`

Check warning on line 36 in src/cfg/manifest.rs

View workflow job for this annotation

GitHub Actions / Check

unused variable: `bootstrap_option`

Check warning on line 36 in src/cfg/manifest.rs

View workflow job for this annotation

GitHub Actions / Check

unused variable: `serializer`
) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
todo!()
}
}

dyn_clone::clone_trait_object!(BootstrapOption);

// todo: rewrite everything
#[derive(Deserialize, Debug, Clone, Serialize)]
pub struct Manifest {
Expand Down Expand Up @@ -156,5 +171,6 @@ pub struct Output {
// bootstrapping options
// todo: make this some kind of enum? or a vec of generic options?
// Box<dyn BootstrapOption> or something...
#[serde(with = "bootstrap_option_serde")]
pub bootstrap: Box<dyn BootstrapOption>,
}

0 comments on commit 0a68a40

Please sign in to comment.