From e5ce5053e1e1214be98c3e1c24148ad6e453f82e Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Tue, 12 Nov 2024 11:43:00 -0800 Subject: [PATCH] fixup: roundtrip_to_exact_type: use type_name instead of manually passing action_tag --- src/cli/subcommand/split_receipt.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/cli/subcommand/split_receipt.rs b/src/cli/subcommand/split_receipt.rs index 06b1ed818..47f98f647 100644 --- a/src/cli/subcommand/split_receipt.rs +++ b/src/cli/subcommand/split_receipt.rs @@ -173,9 +173,8 @@ async fn two_phased_can_parse_receipt_perfectly( let inner_typetag_name = action.inner_typetag_name(); match inner_typetag_name { action_tag if action_tag == crate::action::common::ProvisionNix::action_tag().0 => { - let action_unjson = roundtrip_to_extract_type::( - action, action_tag, - )?; + let action_unjson = + roundtrip_to_extract_type::(action)?; tracing::debug!( "Marking provision_nix as skipped so we don't undo it until phase 2" @@ -196,9 +195,8 @@ async fn two_phased_can_parse_receipt_perfectly( } }, action_tag if action_tag == crate::action::base::CreateDirectory::action_tag().0 => { - let action_unjson = roundtrip_to_extract_type::< - crate::action::base::CreateDirectory, - >(action, action_tag)?; + let action_unjson = + roundtrip_to_extract_type::(action)?; // NOTE(cole-h): we check if it stars with /nix, in case we start creating more // directories in the "toplevel" actions @@ -221,9 +219,8 @@ async fn two_phased_can_parse_receipt_perfectly( } }, action_tag if action_tag == crate::action::macos::CreateNixVolume::action_tag().0 => { - let action_unjson = roundtrip_to_extract_type::< - crate::action::macos::CreateNixVolume, - >(action, action_tag)?; + let action_unjson = + roundtrip_to_extract_type::(action)?; tracing::debug!("Marking create_volume, encrypt_volume (if it happened), unmount_volume as skipped so we don't undo it until phase 2"); @@ -256,7 +253,7 @@ async fn two_phased_can_parse_receipt_perfectly( { let action_unjson = roundtrip_to_extract_type::< crate::action::macos::CreateDeterminateNixVolume, - >(action, action_tag)?; + >(action)?; tracing::debug!("Marking create_volume, encrypt_volume, unmount_volume as skipped so we don't undo it until phase 2"); @@ -466,14 +463,14 @@ async fn two_phased_cannot_parse_receipt_perfectly( fn roundtrip_to_extract_type( action: &StatefulAction>, - action_tag: &str, ) -> eyre::Result> { + let action_name = std::any::type_name::(); let action_json = serde_json::to_string(action).with_context(|| { - format!("serde_json::to_string'ing {action_tag} json to extract real type") + format!("serde_json::to_string'ing {action_name} json to extract real type") })?; let action_unjson: StatefulAction = serde_json::from_str(&action_json).with_context(|| { - format!("serde_json::from_str'ing {action_tag} json to extract real type") + format!("serde_json::from_str'ing {action_name} json to extract real type") })?; Ok(action_unjson)