From bc2bb6b4962b5b9e3e37c420b7d5dbee856f9487 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Wed, 31 Jan 2024 20:08:14 +1300 Subject: [PATCH 1/7] Change `ItemId` struct into a trait. --- crate/core/src/item_id.rs | 63 ++++++++++++++++++++++++++++++--------- crate/core/src/lib.rs | 2 +- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/crate/core/src/item_id.rs b/crate/core/src/item_id.rs index e457b1ff7..ef78421b4 100644 --- a/crate/core/src/item_id.rs +++ b/crate/core/src/item_id.rs @@ -1,24 +1,59 @@ -use std::borrow::Cow; +use std::{fmt::Debug, hash::Hash}; -use serde::{Deserialize, Serialize}; +use serde::{de::Deserialize, Serialize}; -/// Unique identifier for an `ItemId`, `Cow<'static, str>` newtype. +/// Unique identifier for an `Item`. /// -/// Must begin with a letter or underscore, and contain only letters, numbers, -/// and underscores. +/// This is a flat enum, where each variant represents an item managed by the +/// automation software. /// /// # Examples /// -/// The following are all examples of valid `ItemId`s: +/// The following /// /// ```rust -/// # use peace_core::{item_id, ItemId}; -/// # -/// let _snake = item_id!("snake_case"); -/// let _camel = item_id!("camelCase"); -/// let _pascal = item_id!("PascalCase"); +/// use peace_core::ItemId; +/// use serde::{Deserialize, Serialize}; +/// +/// #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)] +/// #[serde(rename_all = "snake_case")] +/// pub enum EnvmanItemId { +/// AppDownload, +/// AppExtract, +/// IamPolicy, +/// IamRole, +/// InstanceProfile, +/// S3Bucket, +/// S3Object, +/// } /// ``` -#[derive(Clone, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)] -pub struct ItemId(Cow<'static, str>); +/// +/// # Design Note +/// +/// TODO: Experiment with upgrades. +/// +/// For compatibility and migrating item IDs deployed with old versions of +/// the automation software, experiment with the following: +/// +/// * developers should provide a `#[serde(from = "FromType")]` implementation, +/// where the `FromType` contains the `ItemId`s from previous automation +/// software versions. +/// * the `ItemId` implementation is a hierarchical enum, with a variant for +/// each version of the automation software's items. +pub trait ItemId: + Clone + Copy + Debug + Hash + PartialEq + Eq + for<'de> Deserialize<'de> + Serialize + 'static +{ +} -crate::id_newtype!(ItemId, ItemIdInvalidFmt, item_id, code_inline); +impl ItemId for T where + T: Clone + + Copy + + Debug + + Hash + + PartialEq + + Eq + + for<'de> Deserialize<'de> + + Serialize + + 'static +{ +} diff --git a/crate/core/src/lib.rs b/crate/core/src/lib.rs index 333f07cfa..565f70de9 100644 --- a/crate/core/src/lib.rs +++ b/crate/core/src/lib.rs @@ -19,7 +19,7 @@ pub use crate::{ app_name::{AppName, AppNameInvalidFmt}, apply_check::ApplyCheck, flow_id::{FlowId, FlowIdInvalidFmt}, - item_id::{ItemId, ItemIdInvalidFmt}, + item_id::ItemId, profile::{Profile, ProfileInvalidFmt}, }; From 8c942939a47a7c1f5ccb6730ec8d1e7e443ad1b2 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Thu, 1 Feb 2024 07:25:17 +1300 Subject: [PATCH 2/7] Text replace `ItemId` with `ItemidT`. --- crate/cfg/src/accessors/stored.rs | 20 ++++++++++------- crate/cfg/src/fn_ctx.rs | 4 ++-- crate/cmd_model/src/cmd_block_outcome.rs | 2 +- crate/cmd_model/src/cmd_outcome.rs | 2 +- .../src/stream_outcome_and_errors.rs | 2 +- crate/cmd_rt/src/cmd_block/cmd_block_error.rs | 2 +- crate/cmd_rt/src/progress.rs | 8 +++---- crate/code_gen/src/cmd/impl_common_fns.rs | 2 +- crate/code_gen/src/cmd/struct_definition.rs | 4 ++-- crate/core/src/lib.rs | 2 +- crate/core/src/progress/progress_sender.rs | 6 ++--- .../src/progress/progress_update_and_id.rs | 4 ++-- crate/data/src/accessors/r_maybe.rs | 5 +++-- crate/data/src/accessors/w_maybe.rs | 5 +++-- crate/data/src/data.rs | 21 +++++++++++++----- crate/data_derive/src/lib.rs | 2 +- crate/params/src/params_specs.rs | 12 +++++----- crate/params/src/value_resolution_ctx.rs | 4 ++-- .../resources/src/internal/state_diffs_mut.rs | 16 +++++++------- crate/resources/src/internal/states_mut.rs | 16 +++++++------- crate/resources/src/states.rs | 16 +++++++------- crate/resources/src/states/state_diffs.rs | 12 +++++----- crate/resources/src/states/states_serde.rs | 22 +++++++++---------- .../rt/src/cmd_blocks/apply_exec_cmd_block.rs | 10 ++++----- crate/rt/src/cmd_blocks/diff_cmd_block.rs | 4 ++-- .../states_current_read_cmd_block.rs | 2 +- .../cmd_blocks/states_discover_cmd_block.rs | 18 +++++++-------- .../cmd_blocks/states_goal_read_cmd_block.rs | 2 +- crate/rt/src/cmds/diff_cmd.rs | 6 ++--- crate/rt_model/src/item_rt.rs | 4 ++-- crate/rt_model/src/item_wrapper.rs | 8 +++---- crate/rt_model/src/params_specs_type_reg.rs | 4 ++-- crate/rt_model/src/states_serializer.rs | 10 ++++----- crate/rt_model/src/states_type_reg.rs | 4 ++-- .../rt_model_core/src/cmd_progress_tracker.rs | 8 +++---- crate/rt_model_core/src/error.rs | 4 ++-- .../src/items_state_stored_stale.rs | 12 +++++----- examples/download/src/lib.rs | 2 +- .../peace_aws_iam_policy/iam_policy_item.rs | 2 +- .../items/peace_aws_iam_role/iam_role_item.rs | 2 +- .../instance_profile_item.rs | 2 +- .../peace_aws_s3_bucket/s3_bucket_item.rs | 2 +- .../peace_aws_s3_object/s3_object_item.rs | 2 +- examples/envman/src/output.rs | 4 ++-- examples/envman/src/web/flow_dot_renderer.rs | 4 ++-- items/blank/src/blank_item.rs | 2 +- items/file_download/src/file_download_item.rs | 4 ++-- items/sh_cmd/src/sh_cmd_item.rs | 4 ++-- items/tar_x/src/tar_x_item.rs | 2 +- workspace_tests/src/cfg/item_id.rs | 2 +- workspace_tests/src/items/sh_cmd_item.rs | 2 +- workspace_tests/src/items/tar_x_item.rs | 2 +- workspace_tests/src/mock_item.rs | 2 +- .../src/rt/cmds/states_discover_cmd.rs | 2 +- workspace_tests/src/vec_copy_item.rs | 2 +- 55 files changed, 173 insertions(+), 156 deletions(-) diff --git a/crate/cfg/src/accessors/stored.rs b/crate/cfg/src/accessors/stored.rs index bd06692b0..30c3ae3db 100644 --- a/crate/cfg/src/accessors/stored.rs +++ b/crate/cfg/src/accessors/stored.rs @@ -17,31 +17,35 @@ use serde::Serialize; /// The previously stored `T` state, if any. #[derive(Debug)] -pub struct Stored<'borrow, T> { +pub struct Stored<'borrow, ItemIdT, T> { /// ID of the item the state should be retrieved for. - item_id: &'borrow ItemId, + item_id: ItemIdT, /// The borrowed `StatesCurrentStored`. states_current_stored: Option>, /// Marker. marker: PhantomData, } -impl<'borrow, T> Stored<'borrow, T> +impl<'borrow, ItemIdT, T> Stored<'borrow, ItemIdT, T> where + ItemIdT: ItemId, T: Clone + Debug + DataType + Display + Serialize + Send + Sync + 'static, { pub fn get(&'borrow self) -> Option<&'borrow T> { self.states_current_stored .as_ref() - .and_then(|states_current_stored| states_current_stored.get(self.item_id)) + .and_then(|states_current_stored| states_current_stored.get(&self.item_id)) } } -impl<'borrow, T> Data<'borrow> for Stored<'borrow, T> +impl<'borrow, ItemIdT, T> Data<'borrow> for Stored<'borrow, ItemIdT, T> where + ItemIdT: ItemId, T: Debug + Send + Sync + 'static, { - fn borrow(item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { + type ItemId = ItemIdT; + + fn borrow(item_id: &'borrow ItemIdT, resources: &'borrow Resources) -> Self { let states_current_stored = resources .try_borrow::() .map_err(|borrow_fail| match borrow_fail { @@ -60,7 +64,7 @@ where } } -impl<'borrow, T> DataAccess for Stored<'borrow, T> { +impl<'borrow, ItemIdT, T> DataAccess for Stored<'borrow, ItemIdT, T> { fn borrows() -> TypeIds where Self: Sized, @@ -78,7 +82,7 @@ impl<'borrow, T> DataAccess for Stored<'borrow, T> { } } -impl<'borrow, T> DataAccessDyn for Stored<'borrow, T> { +impl<'borrow, ItemIdT, T> DataAccessDyn for Stored<'borrow, ItemIdT, T> { fn borrows(&self) -> TypeIds where Self: Sized, diff --git a/crate/cfg/src/fn_ctx.rs b/crate/cfg/src/fn_ctx.rs index 31289bd31..50a061efc 100644 --- a/crate/cfg/src/fn_ctx.rs +++ b/crate/cfg/src/fn_ctx.rs @@ -9,7 +9,7 @@ use peace_core::progress::ProgressSender; #[derive(Clone, Copy, Debug)] pub struct FnCtx<'exec> { /// ID of the item this belongs to. - pub item_id: &'exec ItemId, + pub item_id: &'exec ItemIdT, /// For items to submit progress updates. #[cfg(feature = "output_progress")] pub progress_sender: ProgressSender<'exec>, @@ -20,7 +20,7 @@ pub struct FnCtx<'exec> { impl<'exec> FnCtx<'exec> { /// Returns a new `OpCtx`. pub fn new( - item_id: &'exec ItemId, + item_id: &'exec ItemIdT, #[cfg(feature = "output_progress")] progress_sender: ProgressSender<'exec>, ) -> Self { Self { diff --git a/crate/cmd_model/src/cmd_block_outcome.rs b/crate/cmd_model/src/cmd_block_outcome.rs index 5092d7095..b65506f41 100644 --- a/crate/cmd_model/src/cmd_block_outcome.rs +++ b/crate/cmd_model/src/cmd_block_outcome.rs @@ -39,7 +39,7 @@ pub enum CmdBlockOutcome { /// The values returned per item. stream_outcome: StreamOutcome, /// Errors from the command execution. - errors: IndexMap, + errors: IndexMap, }, } diff --git a/crate/cmd_model/src/cmd_outcome.rs b/crate/cmd_model/src/cmd_outcome.rs index 643e7353d..1c3a9db56 100644 --- a/crate/cmd_model/src/cmd_outcome.rs +++ b/crate/cmd_model/src/cmd_outcome.rs @@ -60,7 +60,7 @@ pub enum CmdOutcome { /// The first block in this list is the one that erred. cmd_blocks_not_processed: Vec, /// Item error(s) from the last command block's execution. - errors: IndexMap, + errors: IndexMap, }, } diff --git a/crate/cmd_model/src/stream_outcome_and_errors.rs b/crate/cmd_model/src/stream_outcome_and_errors.rs index 852ec4f3d..1e525f04b 100644 --- a/crate/cmd_model/src/stream_outcome_and_errors.rs +++ b/crate/cmd_model/src/stream_outcome_and_errors.rs @@ -8,5 +8,5 @@ pub struct StreamOutcomeAndErrors { /// The `CmdBlock` stream outcome. pub stream_outcome: StreamOutcome, /// The errors during processing, - pub errors: IndexMap, + pub errors: IndexMap, } diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs index c4f9a031a..896c6612a 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs @@ -44,7 +44,7 @@ where /// The outcome value. stream_outcome: StreamOutcome, /// Item error(s) from the last command block's execution. - errors: IndexMap, + errors: IndexMap, }, /// An interrupt signal was received while the `CmdBlock` was executing. #[error("`CmdBlock` item logic failed.")] diff --git a/crate/cmd_rt/src/progress.rs b/crate/cmd_rt/src/progress.rs index 5f120d45e..b9e45746e 100644 --- a/crate/cmd_rt/src/progress.rs +++ b/crate/cmd_rt/src/progress.rs @@ -6,7 +6,7 @@ use peace_cfg::{ CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressStatus, ProgressTracker, ProgressUpdate, ProgressUpdateAndId, }, - ItemId, + ItemIdT, }; use peace_rt_model::{output::OutputWrite, IndexMap}; use tokio::sync::mpsc::Receiver; @@ -18,7 +18,7 @@ impl Progress { // TODO: write test for this pub async fn progress_render( output: &mut O, - progress_trackers: &mut IndexMap, + progress_trackers: &mut IndexMap, mut cmd_progress_rx: Receiver, ) where O: OutputWrite, @@ -32,7 +32,7 @@ impl Progress { async fn handle_cmd_progress_update( output: &mut O, - progress_trackers: &mut IndexMap, + progress_trackers: &mut IndexMap, cmd_progress_update: CmdProgressUpdate, ) -> ControlFlow<()> where @@ -102,7 +102,7 @@ impl Progress { async fn handle_progress_update_and_id( output: &mut O, - progress_trackers: &mut IndexMap, + progress_trackers: &mut IndexMap, progress_update_and_id: ProgressUpdateAndId, ) where O: OutputWrite, diff --git a/crate/code_gen/src/cmd/impl_common_fns.rs b/crate/code_gen/src/cmd/impl_common_fns.rs index ad58c50fb..545748ca7 100644 --- a/crate/code_gen/src/cmd/impl_common_fns.rs +++ b/crate/code_gen/src/cmd/impl_common_fns.rs @@ -39,7 +39,7 @@ pub fn impl_common_fns(scope_struct: &ScopeStruct) -> proc_macro2::TokenStream { /// Note: this **must** be called for each item in the flow. pub fn with_item_params( mut self, - item_id: peace_cfg::ItemId, + item_id: peace_cfg::ItemIdT, params_spec: as peace_params::Params>::Spec, ) -> Self where diff --git a/crate/code_gen/src/cmd/struct_definition.rs b/crate/code_gen/src/cmd/struct_definition.rs index f4b2c53c6..ee290a433 100644 --- a/crate/code_gen/src/cmd/struct_definition.rs +++ b/crate/code_gen/src/cmd/struct_definition.rs @@ -37,7 +37,7 @@ use crate::cmd::scope_struct::ScopeStruct; /// pub(crate) profile_params_selection: CmdCtxBuilderTypesT::ProfileParamsSelection, /// /// Flow parameters. /// pub(crate) flow_params_selection: CmdCtxBuilderTypesT::FlowParamsSelection, -/// /// Map of item ID to its parameters. `TypeMap` newtype. +/// /// Map of item ID to its parameters. `TypeMap` newtype. /// pub(crate) params_specs_provided: peace_params::ParamsSpecs, /// } /// ``` @@ -129,7 +129,7 @@ mod fields { pub fn params_specs_push(fields_named: &mut FieldsNamed, scope: Scope) { if scope.flow_count() == FlowCount::One { let fields_params_specs: FieldsNamed = parse_quote!({ - /// Map of item ID to its parameters. `TypeMap` newtype. + /// Map of item ID to its parameters. `TypeMap` newtype. pub(crate) params_specs_provided: peace_params::ParamsSpecs }); fields_named.named.extend(fields_params_specs.named); diff --git a/crate/core/src/lib.rs b/crate/core/src/lib.rs index 565f70de9..594f56449 100644 --- a/crate/core/src/lib.rs +++ b/crate/core/src/lib.rs @@ -4,7 +4,7 @@ //! //! * `peace_cfg` has a dependency on `peace_resources` for `Resources`, used in //! `Item::setup`. -//! * `peace_resources` has a dependency on `ItemId`, as uses `TypeMap` for the `States` maps. //! //! When [peace#67] is implemented, the `progress` module can be moved out diff --git a/crate/core/src/progress/progress_sender.rs b/crate/core/src/progress/progress_sender.rs index ba228306b..f75c3469e 100644 --- a/crate/core/src/progress/progress_sender.rs +++ b/crate/core/src/progress/progress_sender.rs @@ -4,21 +4,21 @@ use crate::{ progress::{ CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressUpdate, ProgressUpdateAndId, }, - ItemId, + ItemIdT, }; /// Submits progress for an item's `ApplyFns::exec` method. #[derive(Clone, Copy, Debug)] pub struct ProgressSender<'exec> { /// ID of the item this belongs to. - item_id: &'exec ItemId, + item_id: &'exec ItemIdT, /// Channel sender to send progress updates to. progress_tx: &'exec Sender, } impl<'exec> ProgressSender<'exec> { /// Returns a new `ProgressSender`. - pub fn new(item_id: &'exec ItemId, progress_tx: &'exec Sender) -> Self { + pub fn new(item_id: &'exec ItemIdT, progress_tx: &'exec Sender) -> Self { Self { item_id, progress_tx, diff --git a/crate/core/src/progress/progress_update_and_id.rs b/crate/core/src/progress/progress_update_and_id.rs index 7d34a43c5..8306f486b 100644 --- a/crate/core/src/progress/progress_update_and_id.rs +++ b/crate/core/src/progress/progress_update_and_id.rs @@ -2,14 +2,14 @@ use serde::{Deserialize, Serialize}; use crate::{ progress::{ProgressMsgUpdate, ProgressUpdate}, - ItemId, + ItemIdT, }; /// An item ID and its progress update. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct ProgressUpdateAndId { /// ID of the item whose progress is updated. - pub item_id: ItemId, + pub item_id: ItemIdT, /// Delta update for the progress tracker. pub progress_update: ProgressUpdate, /// Whether to change the progress message. diff --git a/crate/data/src/accessors/r_maybe.rs b/crate/data/src/accessors/r_maybe.rs index e21ea9a1f..dbe492fc8 100644 --- a/crate/data/src/accessors/r_maybe.rs +++ b/crate/data/src/accessors/r_maybe.rs @@ -4,7 +4,6 @@ use fn_graph::{ resman::{BorrowFail, Ref}, DataAccess, DataAccessDyn, Resources, TypeIds, }; -use peace_core::ItemId; use crate::Data; @@ -42,7 +41,9 @@ impl<'borrow, T> Data<'borrow> for RMaybe<'borrow, T> where T: Debug + Send + Sync + 'static, { - fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { + type ItemId = (); + + fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { resources .try_borrow::() .map_err(|borrow_fail| match borrow_fail { diff --git a/crate/data/src/accessors/w_maybe.rs b/crate/data/src/accessors/w_maybe.rs index 13d06d8c3..9cbede839 100644 --- a/crate/data/src/accessors/w_maybe.rs +++ b/crate/data/src/accessors/w_maybe.rs @@ -4,7 +4,6 @@ use fn_graph::{ resman::{BorrowFail, RefMut}, DataAccess, DataAccessDyn, Resources, TypeIds, }; -use peace_core::ItemId; use crate::Data; @@ -51,7 +50,9 @@ impl<'borrow, T> Data<'borrow> for WMaybe<'borrow, T> where T: Debug + Send + Sync + 'static, { - fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { + type ItemId = (); + + fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { resources .try_borrow_mut::() .map_err(|borrow_fail| match borrow_fail { diff --git a/crate/data/src/data.rs b/crate/data/src/data.rs index 15ff4f6e7..144bf355d 100644 --- a/crate/data/src/data.rs +++ b/crate/data/src/data.rs @@ -11,6 +11,9 @@ use peace_core::ItemId; /// /// [`Data` derive]: peace_data_derive::Data pub trait Data<'borrow>: DataAccess + DataAccessDyn + Send { + /// The `ItemId` enum defined by the application software. + type ItemId: ItemId; + /// Borrows each of `Self`'s fields from the provided [`Resources`]. /// /// This takes in the `item_id`, so that the type that implements this @@ -21,15 +24,19 @@ pub trait Data<'borrow>: DataAccess + DataAccessDyn + Send { /// /// * `item_id`: ID of the item this borrow is used for. /// * `resources`: `Any` map to borrow the data from. - fn borrow(item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self; + fn borrow(item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self; } impl<'borrow> Data<'borrow> for () { - fn borrow(_item_id: &'borrow ItemId, _resources: &'borrow Resources) -> Self {} + type ItemId = (); + + fn borrow(_item_id: &'borrow Self::ItemId, _resources: &'borrow Resources) -> Self {} } impl<'borrow> Data<'borrow> for &'borrow () { - fn borrow(_item_id: &'borrow ItemId, _resources: &'borrow Resources) -> Self { + type ItemId = (); + + fn borrow(_item_id: &'borrow Self::ItemId, _resources: &'borrow Resources) -> Self { &() } } @@ -38,7 +45,9 @@ impl<'borrow, T> Data<'borrow> for R<'borrow, T> where T: Debug + Send + Sync + 'static, { - fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { + type ItemId = (); + + fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { ::borrow(resources) } } @@ -47,7 +56,9 @@ impl<'borrow, T> Data<'borrow> for W<'borrow, T> where T: Debug + Send + Sync + 'static, { - fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { + type ItemId = (); + + fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { ::borrow(resources) } } diff --git a/crate/data_derive/src/lib.rs b/crate/data_derive/src/lib.rs index 05091fe23..e2989c15a 100644 --- a/crate/data_derive/src/lib.rs +++ b/crate/data_derive/src/lib.rs @@ -121,7 +121,7 @@ fn impl_data_access(ast: &DeriveInput) -> proc_macro2::TokenStream { for #name #ty_generics #where_clause { - fn borrow(item_id: & #impl_borrow_lt #peace_cfg_path::ItemId, resources: & #impl_borrow_lt #peace_data_path::Resources) -> Self { + fn borrow(item_id: & #impl_borrow_lt #peace_cfg_path::ItemIdT, resources: & #impl_borrow_lt #peace_data_path::Resources) -> Self { #borrow_return } } diff --git a/crate/params/src/params_specs.rs b/crate/params/src/params_specs.rs index 56e9a7b10..76d3d06ad 100644 --- a/crate/params/src/params_specs.rs +++ b/crate/params/src/params_specs.rs @@ -6,7 +6,7 @@ use serde::Serialize; use crate::AnySpecRtBoxed; -/// Map of item ID to its params' specs. `TypeMap` newtype. /// /// The concrete `*ValueSpec` type can be obtained by calling @@ -26,7 +26,7 @@ use crate::AnySpecRtBoxed; /// different in what they are doing. #[derive(Clone, Debug, Default, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct ParamsSpecs(TypeMap); +pub struct ParamsSpecs(TypeMap); impl ParamsSpecs { /// Returns a new `ParamsSpecs` map. @@ -44,13 +44,13 @@ impl ParamsSpecs { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } impl Deref for ParamsSpecs { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -63,8 +63,8 @@ impl DerefMut for ParamsSpecs { } } -impl From> for ParamsSpecs { - fn from(type_map: TypeMap) -> Self { +impl From> for ParamsSpecs { + fn from(type_map: TypeMap) -> Self { Self(type_map) } } diff --git a/crate/params/src/value_resolution_ctx.rs b/crate/params/src/value_resolution_ctx.rs index 7f9edc240..f9c753345 100644 --- a/crate/params/src/value_resolution_ctx.rs +++ b/crate/params/src/value_resolution_ctx.rs @@ -11,7 +11,7 @@ pub struct ValueResolutionCtx { /// `Goal`. value_resolution_mode: ValueResolutionMode, /// ID of the item whose params are being resolved. - item_id: ItemId, + item_id: ItemIdT, /// Name of the `Item::Params` type. params_type_name: String, /// Hierarchy of fields traversed to resolve this value. @@ -21,7 +21,7 @@ pub struct ValueResolutionCtx { impl ValueResolutionCtx { pub fn new( value_resolution_mode: ValueResolutionMode, - item_id: ItemId, + item_id: ItemIdT, params_type_name: String, ) -> Self { Self { diff --git a/crate/resources/src/internal/state_diffs_mut.rs b/crate/resources/src/internal/state_diffs_mut.rs index 270dfc24e..347769299 100644 --- a/crate/resources/src/internal/state_diffs_mut.rs +++ b/crate/resources/src/internal/state_diffs_mut.rs @@ -4,7 +4,7 @@ use peace_core::ItemId; use serde::Serialize; use type_reg::untagged::{BoxDtDisplay, TypeMap}; -/// Diffs of `State`s for each `Item`s. `TypeMap` +/// Diffs of `State`s for each `Item`s. `TypeMap` /// newtype. /// /// # Implementors @@ -15,7 +15,7 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// [`StateDiffs`]: crate::StateDiffs /// [`Resources`]: crate::Resources #[derive(Debug, Default, Serialize)] -pub struct StateDiffsMut(TypeMap); +pub struct StateDiffsMut(TypeMap); impl StateDiffsMut { /// Returns a new `StateDiffsMut` map. @@ -32,13 +32,13 @@ impl StateDiffsMut { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } impl Deref for StateDiffsMut { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -51,14 +51,14 @@ impl DerefMut for StateDiffsMut { } } -impl From> for StateDiffsMut { - fn from(type_map: TypeMap) -> Self { +impl From> for StateDiffsMut { + fn from(type_map: TypeMap) -> Self { Self(type_map) } } -impl Extend<(ItemId, BoxDtDisplay)> for StateDiffsMut { - fn extend>(&mut self, iter: T) { +impl Extend<(ItemIdT, BoxDtDisplay)> for StateDiffsMut { + fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state_diff)| { self.insert_raw(item_id, state_diff); }); diff --git a/crate/resources/src/internal/states_mut.rs b/crate/resources/src/internal/states_mut.rs index f76b7eb1c..089ef86ac 100644 --- a/crate/resources/src/internal/states_mut.rs +++ b/crate/resources/src/internal/states_mut.rs @@ -7,7 +7,7 @@ use peace_core::ItemId; use serde::Serialize; use type_reg::untagged::{BoxDtDisplay, TypeMap}; -/// `State`s for all `Item`s. `TypeMap` newtype. +/// `State`s for all `Item`s. `TypeMap` newtype. /// /// # Implementors /// @@ -26,7 +26,7 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// [`StatesCurrent`]: crate::StatesCurrent /// [`StatesRw`]: crate::StatesRw #[derive(Debug, Serialize)] -pub struct StatesMut(TypeMap, PhantomData); +pub struct StatesMut(TypeMap, PhantomData); impl StatesMut { /// Returns a new `StatesMut` map. @@ -43,7 +43,7 @@ impl StatesMut { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } @@ -55,7 +55,7 @@ impl Default for StatesMut { } impl Deref for StatesMut { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -68,14 +68,14 @@ impl DerefMut for StatesMut { } } -impl From> for StatesMut { - fn from(type_map: TypeMap) -> Self { +impl From> for StatesMut { + fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } -impl Extend<(ItemId, BoxDtDisplay)> for StatesMut { - fn extend>(&mut self, iter: T) { +impl Extend<(ItemIdT, BoxDtDisplay)> for StatesMut { + fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state)| { self.insert_raw(item_id, state); }); diff --git a/crate/resources/src/states.rs b/crate/resources/src/states.rs index 6a352dc8e..de5249eae 100644 --- a/crate/resources/src/states.rs +++ b/crate/resources/src/states.rs @@ -33,7 +33,7 @@ mod states_goal_stored; mod states_previous; mod states_serde; -/// Map of `State`s for all `Item`s. `TypeMap` newtype. +/// Map of `State`s for all `Item`s. `TypeMap` newtype. /// /// # Type Parameters /// @@ -51,7 +51,7 @@ mod states_serde; /// regardless of whether a `State` is recorded for that item. /// /// 2. Inserting an `Option<_>` layer around the `Item::State` turns the map -/// into a `Map>`. +/// into a `Map>`. /// /// 3. Calling `states.get(item_id)` returns `Option>`, the /// outer layer for whether the item had an entry, and the inner layer for @@ -92,7 +92,7 @@ mod states_serde; /// /// ## `StatesSerde` Separate Type /// -/// Newtype for `Map>`. +/// Newtype for `Map>`. /// /// ### Item Additions /// @@ -146,7 +146,7 @@ mod states_serde; #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. pub struct States( - pub(crate) TypeMap, + pub(crate) TypeMap, pub(crate) PhantomData, ); @@ -165,7 +165,7 @@ impl States { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } @@ -190,15 +190,15 @@ impl Default for States { } impl Deref for States { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 } } -impl From> for States { - fn from(type_map: TypeMap) -> Self { +impl From> for States { + fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } diff --git a/crate/resources/src/states/state_diffs.rs b/crate/resources/src/states/state_diffs.rs index 34b56948a..0bc95c56c 100644 --- a/crate/resources/src/states/state_diffs.rs +++ b/crate/resources/src/states/state_diffs.rs @@ -7,7 +7,7 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; use crate::internal::StateDiffsMut; -/// Diffs of `State`s for each `Item`s. `TypeMap` +/// Diffs of `State`s for each `Item`s. `TypeMap` /// newtype. /// /// [`External`] fields are not necessarily used in `StateDiff` computations. @@ -20,7 +20,7 @@ use crate::internal::StateDiffsMut; /// [`External`]: peace_cfg::state::External /// [`Resources`]: crate::Resources #[derive(Debug, Default, Serialize)] -pub struct StateDiffs(TypeMap); +pub struct StateDiffs(TypeMap); impl StateDiffs { /// Returns a new `StateDiffs` map. @@ -37,21 +37,21 @@ impl StateDiffs { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } impl Deref for StateDiffs { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 } } -impl From> for StateDiffs { - fn from(type_map: TypeMap) -> Self { +impl From> for StateDiffs { + fn from(type_map: TypeMap) -> Self { Self(type_map) } } diff --git a/crate/resources/src/states/states_serde.rs b/crate/resources/src/states/states_serde.rs index 4077e58a2..c5aea647b 100644 --- a/crate/resources/src/states/states_serde.rs +++ b/crate/resources/src/states/states_serde.rs @@ -9,10 +9,10 @@ use type_reg::{ untagged::{BoxDtDisplay, TypeMapOpt}, }; -/// Map of `State`s for all `Item`s. `TypeMapOpt` +/// Map of `State`s for all `Item`s. `TypeMapOpt` /// newtype. /// -/// Conceptually you can think of this as a `Map>`. +/// Conceptually you can think of this as a `Map>`. /// /// This map should: /// @@ -23,12 +23,12 @@ use type_reg::{ /// /// * Deserialization. /// * `From<&ItemGraph>`: All states are initialized to `None`. -/// * [`FromIterator::<(ItemId, Option)>::from_iter`]. +/// * [`FromIterator::<(ItemIdT, Option)>::from_iter`]. /// -/// [`FromIterator::<(ItemId, Option)>::from_iter`]: std::iter::FromIterator +/// [`FromIterator::<(ItemIdT, Option)>::from_iter`]: std::iter::FromIterator #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct StatesSerde(TypeMapOpt>) +pub struct StatesSerde(TypeMapOpt>) where ValueT: Clone + Debug + PartialEq + Eq; @@ -45,7 +45,7 @@ where } /// Returns the inner map. - pub fn into_inner(self) -> TypeMapOpt> { + pub fn into_inner(self) -> TypeMapOpt> { self.0 } } @@ -70,18 +70,18 @@ impl Deref for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, { - type Target = TypeMapOpt>; + type Target = TypeMapOpt>; fn deref(&self) -> &Self::Target { &self.0 } } -impl FromIterator<(ItemId, Option)> for StatesSerde +impl FromIterator<(ItemIdT, Option)> for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, { - fn from_iter)>>(iter: T) -> Self { + fn from_iter)>>(iter: T) -> Self { iter.into_iter().fold( Self(TypeMapOpt::new_typed()), |mut states_serde, (item_id, state_boxed)| { @@ -92,12 +92,12 @@ where } } -impl From>> +impl From>> for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, { - fn from(type_map_opt: TypeMapOpt>) -> Self { + fn from(type_map_opt: TypeMapOpt>) -> Self { Self(type_map_opt) } } diff --git a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs index f81310299..0e776cce6 100644 --- a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs @@ -326,7 +326,7 @@ where ( States, States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -349,7 +349,7 @@ where fn outcome_collate( states_applied_mut: &mut StatesMut, states_target_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemApplyOutcome<::AppError>, ) -> Result<(), ::AppError> { let apply_for = StatesTs::apply_for(); @@ -591,18 +591,18 @@ pub enum ItemApplyOutcome { /// Error occurred when discovering current state, goal states, state /// diff, or `ApplyCheck`. PrepareFail { - item_id: ItemId, + item_id: ItemIdT, item_apply_partial: ItemApplyPartialBoxed, error: E, }, /// Ensure execution succeeded. Success { - item_id: ItemId, + item_id: ItemIdT, item_apply: ItemApplyBoxed, }, /// Ensure execution failed. Fail { - item_id: ItemId, + item_id: ItemIdT, item_apply: ItemApplyBoxed, error: E, }, diff --git a/crate/rt/src/cmd_blocks/diff_cmd_block.rs b/crate/rt/src/cmd_blocks/diff_cmd_block.rs index 7c551b57b..c6e656a9f 100644 --- a/crate/rt/src/cmd_blocks/diff_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/diff_cmd_block.rs @@ -67,8 +67,8 @@ where flow: &Flow<::AppError>, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, ::AppError> { let stream_outcome_result = flow .graph() diff --git a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs index 93ebb1751..0c399b29c 100644 --- a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs @@ -41,7 +41,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, ) -> Result::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); diff --git a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs index 5d44ad563..3a4703f8b 100644 --- a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs @@ -221,7 +221,7 @@ where &Result, ::AppError>, >, progress_tx: &Sender, - item_id: &ItemId, + item_id: &ItemIdT, ) { if let Some((progress_update, msg_update)) = DiscoverFor::progress_update( progress_complete_on_success, @@ -244,13 +244,13 @@ where pub enum ItemDiscoverOutcome { /// Discover succeeded. Success { - item_id: ItemId, + item_id: ItemIdT, state_current: Option, state_goal: Option, }, /// Discover failed. Fail { - item_id: ItemId, + item_id: ItemIdT, state_current: Option, state_goal: Option, error: AppErrorT, @@ -353,7 +353,7 @@ where ) -> Result< ( States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -369,7 +369,7 @@ where fn outcome_collate( states_current_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemDiscoverOutcome<::AppError>, ) -> Result<(), ::AppError> { match outcome_partial { @@ -496,7 +496,7 @@ where ) -> Result< ( States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -512,7 +512,7 @@ where fn outcome_collate( states_goal_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemDiscoverOutcome<::AppError>, ) -> Result<(), ::AppError> { match outcome_partial { @@ -656,7 +656,7 @@ where ( States, States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -679,7 +679,7 @@ where fn outcome_collate( states_current_mut: &mut StatesMut, states_goal_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemDiscoverOutcome<::AppError>, ) -> Result<(), ::AppError> { match outcome_partial { diff --git a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs index 8086ca396..bbd6cad9d 100644 --- a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs @@ -41,7 +41,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, ) -> Result::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); diff --git a/crate/rt/src/cmds/diff_cmd.rs b/crate/rt/src/cmds/diff_cmd.rs index e1171864d..e4697973f 100644 --- a/crate/rt/src/cmds/diff_cmd.rs +++ b/crate/rt/src/cmds/diff_cmd.rs @@ -1,7 +1,7 @@ use std::{fmt::Debug, marker::PhantomData}; use futures::{StreamExt, TryStreamExt}; -use peace_cfg::{ItemId, Profile}; +use peace_cfg::{ItemIdT, Profile}; use peace_cmd::{ ctx::{CmdCtx, CmdCtxTypesConstrained}, scopes::{MultiProfileSingleFlow, MultiProfileSingleFlowView, SingleProfileSingleFlow}, @@ -221,8 +221,8 @@ where flow: &Flow<::AppError>, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result::AppError> { let state_diffs = { let state_diffs_mut = flow diff --git a/crate/rt_model/src/item_rt.rs b/crate/rt_model/src/item_rt.rs index 561fe5532..294d29d33 100644 --- a/crate/rt_model/src/item_rt.rs +++ b/crate/rt_model/src/item_rt.rs @@ -156,8 +156,8 @@ pub trait ItemRt: &self, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, E> where E: Debug + std::error::Error; diff --git a/crate/rt_model/src/item_wrapper.rs b/crate/rt_model/src/item_wrapper.rs index 5d617277d..d623e1a7b 100644 --- a/crate/rt_model/src/item_wrapper.rs +++ b/crate/rt_model/src/item_wrapper.rs @@ -243,8 +243,8 @@ where &self, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, E> { let item_id = ::id(self); let state_base = states_a.get::(item_id); @@ -666,8 +666,8 @@ where &self, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, E> { self.state_diff_exec(params_specs, resources, states_a, states_b) .await diff --git a/crate/rt_model/src/params_specs_type_reg.rs b/crate/rt_model/src/params_specs_type_reg.rs index 612e10fa3..b2992ab2b 100644 --- a/crate/rt_model/src/params_specs_type_reg.rs +++ b/crate/rt_model/src/params_specs_type_reg.rs @@ -16,7 +16,7 @@ use peace_resources::type_reg::untagged::TypeReg; /// [`Params`]: peace_cfg::Item::Params /// [`StatesTypeReg`]: crate::StatesTypeReg #[derive(Debug, Default)] -pub struct ParamsSpecsTypeReg(TypeReg); +pub struct ParamsSpecsTypeReg(TypeReg); impl ParamsSpecsTypeReg { /// Returns a new `ParamsSpecsTypeReg`. @@ -26,7 +26,7 @@ impl ParamsSpecsTypeReg { } impl Deref for ParamsSpecsTypeReg { - type Target = TypeReg; + type Target = TypeReg; fn deref(&self) -> &Self::Target { &self.0 diff --git a/crate/rt_model/src/states_serializer.rs b/crate/rt_model/src/states_serializer.rs index 5ccc44f2f..b4e03a6cf 100644 --- a/crate/rt_model/src/states_serializer.rs +++ b/crate/rt_model/src/states_serializer.rs @@ -67,7 +67,7 @@ where pub async fn deserialize_stored( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, ) -> Result { let states = Self::deserialize_internal::( @@ -96,7 +96,7 @@ where pub async fn deserialize_goal( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_goal_file: &StatesGoalFile, ) -> Result { let states = Self::deserialize_internal::( @@ -126,7 +126,7 @@ where pub async fn deserialize_stored_opt( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, ) -> Result, E> { Self::deserialize_internal( @@ -162,7 +162,7 @@ where thread_name: String, flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_file_path: &Path, ) -> Result>, E> where @@ -229,7 +229,7 @@ where async fn deserialize_internal( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_file_path: &Path, ) -> Result>, E> where diff --git a/crate/rt_model/src/states_type_reg.rs b/crate/rt_model/src/states_type_reg.rs index aeda73d79..073b30d7b 100644 --- a/crate/rt_model/src/states_type_reg.rs +++ b/crate/rt_model/src/states_type_reg.rs @@ -17,7 +17,7 @@ use peace_resources::type_reg::untagged::{BoxDtDisplay, TypeReg}; /// [`StatesGoalFile`]: peace_resources::paths::StatesGoalFile /// [`StatesCurrentFile`]: peace_resources::paths::StatesCurrentFile #[derive(Debug, Default)] -pub struct StatesTypeReg(TypeReg); +pub struct StatesTypeReg(TypeReg); impl StatesTypeReg { /// Returns new `StatesTypeReg`. @@ -27,7 +27,7 @@ impl StatesTypeReg { } impl Deref for StatesTypeReg { - type Target = TypeReg; + type Target = TypeReg; fn deref(&self) -> &Self::Target { &self.0 diff --git a/crate/rt_model_core/src/cmd_progress_tracker.rs b/crate/rt_model_core/src/cmd_progress_tracker.rs index 09f78e6f6..7f45b0a0a 100644 --- a/crate/rt_model_core/src/cmd_progress_tracker.rs +++ b/crate/rt_model_core/src/cmd_progress_tracker.rs @@ -18,14 +18,14 @@ pub struct CmdProgressTracker { /// `MultiProgress` that tracks the remaining progress bars. pub multi_progress: MultiProgress, /// Tracks progress for each item. - pub progress_trackers: IndexMap, + pub progress_trackers: IndexMap, } impl CmdProgressTracker { /// Returns a new `CmdProgressTracker`. pub fn new( multi_progress: MultiProgress, - progress_trackers: IndexMap, + progress_trackers: IndexMap, ) -> Self { Self { multi_progress, @@ -45,13 +45,13 @@ impl CmdProgressTracker { } /// Returns the `ProgressTracker`s for each item. - pub fn progress_trackers(&self) -> &IndexMap { + pub fn progress_trackers(&self) -> &IndexMap { &self.progress_trackers } /// Returns a mutable reference to the `ProgressTracker`s for each item /// spec. - pub fn progress_trackers_mut(&mut self) -> &mut IndexMap { + pub fn progress_trackers_mut(&mut self) -> &mut IndexMap { &mut self.progress_trackers } } diff --git a/crate/rt_model_core/src/error.rs b/crate/rt_model_core/src/error.rs index 4f9561d9f..3acf722ad 100644 --- a/crate/rt_model_core/src/error.rs +++ b/crate/rt_model_core/src/error.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use peace_cmd_model::CmdExecutionError; -use peace_core::{FlowId, ItemId, Profile}; +use peace_core::{FlowId, ItemIdT, Profile}; use peace_params::{ParamsResolveError, ParamsSpecs}; use peace_resources::paths::ParamsSpecsFile; @@ -102,7 +102,7 @@ pub enum Error { )] ParamsSpecNotFound { /// Item ID for which the params spec was not found. - item_id: ItemId, + item_id: ItemIdT, }, /// Item params specs do not match with the items in the flow. diff --git a/crate/rt_model_core/src/items_state_stored_stale.rs b/crate/rt_model_core/src/items_state_stored_stale.rs index 9111f376e..6f0c7225c 100644 --- a/crate/rt_model_core/src/items_state_stored_stale.rs +++ b/crate/rt_model_core/src/items_state_stored_stale.rs @@ -7,11 +7,11 @@ use crate::StateStoredAndDiscovered; /// Items whose stored and discovered state are not equal. /// -/// `IndexMap` newtype. +/// `IndexMap` newtype. /// /// This can be used for either current state or goal state. #[derive(Clone, Debug, Default)] -pub struct ItemsStateStoredStale(IndexMap); +pub struct ItemsStateStoredStale(IndexMap); impl ItemsStateStoredStale { /// Returns a new `ItemsStateStoredStale` map. @@ -26,7 +26,7 @@ impl ItemsStateStoredStale { } /// Returns the underlying map. - pub fn into_inner(self) -> IndexMap { + pub fn into_inner(self) -> IndexMap { self.0 } @@ -37,7 +37,7 @@ impl ItemsStateStoredStale { } impl Deref for ItemsStateStoredStale { - type Target = IndexMap; + type Target = IndexMap; fn deref(&self) -> &Self::Target { &self.0 @@ -50,8 +50,8 @@ impl DerefMut for ItemsStateStoredStale { } } -impl FromIterator<(ItemId, StateStoredAndDiscovered)> for ItemsStateStoredStale { - fn from_iter>(iter: I) -> Self { +impl FromIterator<(ItemIdT, StateStoredAndDiscovered)> for ItemsStateStoredStale { + fn from_iter>(iter: I) -> Self { Self(IndexMap::from_iter(iter)) } } diff --git a/examples/download/src/lib.rs b/examples/download/src/lib.rs index ac50cc643..5f185f4c7 100644 --- a/examples/download/src/lib.rs +++ b/examples/download/src/lib.rs @@ -1,5 +1,5 @@ use peace::{ - cfg::{app_name, item_id, FlowId, ItemId, Profile}, + cfg::{app_name, item_id, FlowId, ItemIdT, Profile}, cmd::{ctx::CmdCtx, scopes::SingleProfileSingleFlow}, cmd_model::CmdOutcome, rt::cmds::{ diff --git a/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs b/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs index 147b98da8..26f8e6048 100644 --- a/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs +++ b/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_iam_policy::{ #[derive(Debug)] pub struct IamPolicyItem { /// ID of the instance profile item. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique instance profile parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs b/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs index 976bcfab7..e03a3f1bb 100644 --- a/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs +++ b/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_iam_role::{ #[derive(Debug)] pub struct IamRoleItem { /// ID of the instance profile item. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique instance profile parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs b/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs index 5f03ab917..c9ae9551d 100644 --- a/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs +++ b/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs @@ -31,7 +31,7 @@ use crate::items::peace_aws_instance_profile::{ #[derive(Debug)] pub struct InstanceProfileItem { /// ID of the instance profile item. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique instance profile parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs b/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs index 337a05fea..1e7c2df90 100644 --- a/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs +++ b/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_s3_bucket::{ #[derive(Debug)] pub struct S3BucketItem { /// ID of the S3 bucket item. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique S3 bucket parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs b/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs index 66a41ae4b..4b01145c4 100644 --- a/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs +++ b/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_s3_object::{ #[derive(Debug)] pub struct S3ObjectItem { /// ID of the S3 object item. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique S3 object parameters type. marker: PhantomData, } diff --git a/examples/envman/src/output.rs b/examples/envman/src/output.rs index 275ffc729..84259a349 100644 --- a/examples/envman/src/output.rs +++ b/examples/envman/src/output.rs @@ -1,5 +1,5 @@ use peace::{ - cfg::ItemId, + cfg::ItemIdT, cmd_model::CmdOutcome, fmt::{ presentable::{Heading, HeadingLevel}, @@ -67,7 +67,7 @@ where /// Presents item errors. pub async fn item_errors_present( output: &mut O, - errors: &IndexMap, + errors: &IndexMap, ) -> Result<(), EnvManError> where O: OutputWrite, diff --git a/examples/envman/src/web/flow_dot_renderer.rs b/examples/envman/src/web/flow_dot_renderer.rs index 6e746f0c8..58765cc96 100644 --- a/examples/envman/src/web/flow_dot_renderer.rs +++ b/examples/envman/src/web/flow_dot_renderer.rs @@ -1,4 +1,4 @@ -use peace::{cfg::ItemId, rt_model::Flow}; +use peace::{cfg::ItemIdT, rt_model::Flow}; /// Renders a `Flow` as a GraphViz Dot diagram. /// @@ -157,7 +157,7 @@ impl FlowDotRenderer { ) } - fn edge(&self, src_item_id: &ItemId, target_item_id: &ItemId) -> String { + fn edge(&self, src_item_id: &ItemIdT, target_item_id: &ItemId) -> String { format!(r#"{src_item_id} -> {target_item_id} [minlen = 9]"#) } } diff --git a/items/blank/src/blank_item.rs b/items/blank/src/blank_item.rs index 27d545860..29df5684d 100644 --- a/items/blank/src/blank_item.rs +++ b/items/blank/src/blank_item.rs @@ -20,7 +20,7 @@ use crate::{BlankApplyFns, BlankData, BlankError, BlankParams, BlankState, Blank #[derive(Debug)] pub struct BlankItem { /// ID of the blank item. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique blank parameters type. marker: PhantomData, } diff --git a/items/file_download/src/file_download_item.rs b/items/file_download/src/file_download_item.rs index 111fa97d1..57b21f3ab 100644 --- a/items/file_download/src/file_download_item.rs +++ b/items/file_download/src/file_download_item.rs @@ -1,7 +1,7 @@ use std::{marker::PhantomData, path::Path}; use peace::{ - cfg::{async_trait, state::FetchedOpt, ApplyCheck, FnCtx, Item, ItemId, State}, + cfg::{async_trait, state::FetchedOpt, ApplyCheck, FnCtx, Item, ItemIdT, State}, params::Params, resources::{resources::ts::Empty, Resources}, }; @@ -24,7 +24,7 @@ use crate::{ #[derive(Debug)] pub struct FileDownloadItem { /// ID of the item to download the file. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique download parameters type. marker: PhantomData, } diff --git a/items/sh_cmd/src/sh_cmd_item.rs b/items/sh_cmd/src/sh_cmd_item.rs index 30dd86e04..2fa1a66d1 100644 --- a/items/sh_cmd/src/sh_cmd_item.rs +++ b/items/sh_cmd/src/sh_cmd_item.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use peace::{ - cfg::{async_trait, ApplyCheck, FnCtx, Item, ItemId, State}, + cfg::{async_trait, ApplyCheck, FnCtx, Item, ItemIdT, State}, params::Params, resources::{resources::ts::Empty, Resources}, }; @@ -23,7 +23,7 @@ use crate::{ #[derive(Debug)] pub struct ShCmdItem { /// ID to easily tell what the item command is for. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique command execution parameters type. marker: PhantomData, } diff --git a/items/tar_x/src/tar_x_item.rs b/items/tar_x/src/tar_x_item.rs index 6097e10ba..c5214d1a7 100644 --- a/items/tar_x/src/tar_x_item.rs +++ b/items/tar_x/src/tar_x_item.rs @@ -29,7 +29,7 @@ use crate::{ #[derive(Debug)] pub struct TarXItem { /// ID of the item to extract the tar. - item_id: ItemId, + item_id: ItemIdT, /// Marker for unique tar extraction parameters type. marker: PhantomData, } diff --git a/workspace_tests/src/cfg/item_id.rs b/workspace_tests/src/cfg/item_id.rs index c94fc5945..6da09787a 100644 --- a/workspace_tests/src/cfg/item_id.rs +++ b/workspace_tests/src/cfg/item_id.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, str::FromStr}; use peace::{ - cfg::{ItemId, ItemIdInvalidFmt}, + cfg::{ItemIdInvalidFmt, ItemIdT}, fmt::Presentable, }; diff --git a/workspace_tests/src/items/sh_cmd_item.rs b/workspace_tests/src/items/sh_cmd_item.rs index 20c120f65..d9aa2a4e5 100644 --- a/workspace_tests/src/items/sh_cmd_item.rs +++ b/workspace_tests/src/items/sh_cmd_item.rs @@ -1,5 +1,5 @@ use peace::{ - cfg::{app_name, item_id, profile, FlowId, ItemId, State}, + cfg::{app_name, item_id, profile, FlowId, ItemIdT, State}, cmd::ctx::CmdCtx, cmd_model::CmdOutcome, data::marker::Clean, diff --git a/workspace_tests/src/items/tar_x_item.rs b/workspace_tests/src/items/tar_x_item.rs index 8a1444b70..fa83a1582 100644 --- a/workspace_tests/src/items/tar_x_item.rs +++ b/workspace_tests/src/items/tar_x_item.rs @@ -1,7 +1,7 @@ use std::{io::Cursor, path::PathBuf}; use peace::{ - cfg::{app_name, item_id, profile, ApplyCheck, FlowId, Item, ItemId, Profile}, + cfg::{app_name, item_id, profile, ApplyCheck, FlowId, Item, ItemIdT, Profile}, cmd::{ctx::CmdCtx, scopes::SingleProfileSingleFlowView}, cmd_model::CmdOutcome, data::Data, diff --git a/workspace_tests/src/mock_item.rs b/workspace_tests/src/mock_item.rs index 2644b9828..3d2967d97 100644 --- a/workspace_tests/src/mock_item.rs +++ b/workspace_tests/src/mock_item.rs @@ -27,7 +27,7 @@ where Id: Clone + Debug + Default + Send + Sync + 'static, { /// ID of the item. - id: ItemId, + id: ItemIdT, /// Marker. mock_fns: MockFns, } diff --git a/workspace_tests/src/rt/cmds/states_discover_cmd.rs b/workspace_tests/src/rt/cmds/states_discover_cmd.rs index e04fe7c06..7faf068ce 100644 --- a/workspace_tests/src/rt/cmds/states_discover_cmd.rs +++ b/workspace_tests/src/rt/cmds/states_discover_cmd.rs @@ -736,7 +736,7 @@ async fn goal_runs_state_goal_for_each_item() -> Result<(), Box(); let states_slice = std::fs::read(&*states_goal_file)?; - let mut type_reg = TypeReg::::new_typed(); + let mut type_reg = TypeReg::::new_typed(); type_reg.register::(VecCopyItem::ID_DEFAULT.clone()); let deserializer = serde_yaml::Deserializer::from_slice(&states_slice); diff --git a/workspace_tests/src/vec_copy_item.rs b/workspace_tests/src/vec_copy_item.rs index 62e1c0583..6bf943378 100644 --- a/workspace_tests/src/vec_copy_item.rs +++ b/workspace_tests/src/vec_copy_item.rs @@ -25,7 +25,7 @@ pub type VecCopyItemWrapper = ItemWrapper; #[derive(Clone, Debug)] pub struct VecCopyItem { /// ID of the item. - id: ItemId, + id: ItemIdT, } impl VecCopyItem { From cd338c240c0fe83821629a2217aaa88f59d6f837 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Thu, 1 Feb 2024 18:29:49 +1300 Subject: [PATCH 3/7] A lot of string replacements to add ``. --- crate/cfg/src/accessors/stored.rs | 10 +- .../src/scopes/multi_profile_single_flow.rs | 11 +- .../src/scopes/single_profile_single_flow.rs | 4 +- crate/cmd_model/src/cmd_block_desc.rs | 2 +- crate/cmd_model/src/cmd_execution_error.rs | 28 ++--- crate/cmd_rt/src/cmd_block.rs | 27 ++--- crate/cmd_rt/src/cmd_block/cmd_block_error.rs | 8 +- .../cmd_rt/src/cmd_block/cmd_block_rt_box.rs | 3 +- .../cmd_rt/src/cmd_block/cmd_block_wrapper.rs | 4 +- .../cmd_execution_error_builder.rs | 20 ++-- crate/code_gen/src/cmd/impl_build.rs | 14 +-- crate/core/src/progress/progress_sender.rs | 11 +- .../src/progress/progress_update_and_id.rs | 7 +- crate/params/src/field_wise_spec_rt.rs | 8 +- crate/params/src/mapping_fn.rs | 8 +- crate/params/src/mapping_fn_impl.rs | 36 +++--- crate/params/src/params_resolve_error.rs | 10 +- crate/params/src/params_spec.rs | 22 ++-- crate/params/src/params_spec_fieldless.rs | 22 ++-- crate/params/src/params_specs.rs | 35 +++++- crate/params/src/value_resolution_ctx.rs | 6 +- crate/params/src/value_spec.rs | 22 ++-- crate/params/src/value_spec_rt.rs | 8 +- .../impl_field_wise_spec_rt_for_field_wise.rs | 8 +- ...ld_wise_spec_rt_for_field_wise_external.rs | 16 +-- .../src/impl_value_spec_rt_for_field_wise.rs | 8 +- .../resources/src/internal/state_diffs_mut.rs | 40 +++++-- crate/resources/src/internal/states_mut.rs | 34 ++++-- crate/resources/src/states.rs | 45 ++++++-- crate/resources/src/states/state_diffs.rs | 42 +++++-- crate/resources/src/states/states_clean.rs | 2 +- crate/resources/src/states/states_cleaned.rs | 11 +- .../src/states/states_cleaned_dry.rs | 15 ++- crate/resources/src/states/states_current.rs | 17 ++- .../src/states/states_current_stored.rs | 17 ++- crate/resources/src/states/states_ensured.rs | 14 ++- .../src/states/states_ensured_dry.rs | 15 ++- crate/resources/src/states/states_goal.rs | 11 +- .../src/states/states_goal_stored.rs | 11 +- crate/resources/src/states/states_previous.rs | 11 +- crate/resources/src/states/states_serde.rs | 22 ++-- .../rt/src/cmd_blocks/apply_exec_cmd_block.rs | 28 +++-- .../apply_state_sync_check_cmd_block.rs | 60 +++++----- crate/rt/src/cmd_blocks/diff_cmd_block.rs | 14 +-- .../states_current_read_cmd_block.rs | 7 +- .../cmd_blocks/states_discover_cmd_block.rs | 18 +-- .../cmd_blocks/states_goal_read_cmd_block.rs | 6 +- crate/rt/src/cmds/clean_cmd.rs | 14 +-- crate/rt/src/cmds/ensure_cmd.rs | 38 +++--- crate/rt/src/cmds/states_current_read_cmd.rs | 25 ++-- .../cmds/states_current_stored_display_cmd.rs | 7 +- crate/rt/src/cmds/states_discover_cmd.rs | 71 ++++++------ crate/rt/src/cmds/states_goal_display_cmd.rs | 2 +- crate/rt/src/cmds/states_goal_read_cmd.rs | 13 ++- crate/rt_model/src/item_graph.rs | 7 +- crate/rt_model/src/item_rt.rs | 2 +- crate/rt_model/src/item_wrapper.rs | 38 +++--- crate/rt_model/src/states_serializer.rs | 37 +++--- workspace_tests/src/cfg/stored.rs | 14 +-- .../single_profile_single_flow_builder.rs | 10 +- .../cmd_execution_error_builder.rs | 24 ++-- workspace_tests/src/items/tar_x_item.rs | 2 +- workspace_tests/src/mock_item.rs | 6 +- workspace_tests/src/params/derive.rs | 16 +-- workspace_tests/src/params/mapping_fn_impl.rs | 38 +++--- workspace_tests/src/params/params_spec.rs | 108 +++++++++--------- .../src/params/params_spec_fieldless.rs | 80 +++++++------ .../src/params/value_resolution_ctx.rs | 14 +-- workspace_tests/src/params/value_spec.rs | 80 +++++++------ workspace_tests/src/resources/resources.rs | 4 +- workspace_tests/src/resources/state_diffs.rs | 2 +- .../resources/states/states_cleaned_dry.rs | 2 +- .../src/resources/states/states_current.rs | 2 +- .../resources/states/states_current_stored.rs | 2 +- .../src/resources/states/states_ensured.rs | 2 +- .../resources/states/states_ensured_dry.rs | 2 +- .../src/resources/states/states_goal.rs | 2 +- .../resources/states/states_goal_stored.rs | 2 +- .../src/resources/states/states_previous.rs | 2 +- .../src/rt/cmd_blocks/apply_exec_cmd_block.rs | 44 +++++-- .../apply_state_sync_check_cmd_block.rs | 36 ++++-- .../src/rt/cmd_blocks/diff_cmd_block.rs | 23 +++- .../states_clean_insertion_cmd_block.rs | 2 +- .../states_current_read_cmd_block.rs | 5 +- .../cmd_blocks/states_discover_cmd_block.rs | 9 +- .../cmd_blocks/states_goal_read_cmd_block.rs | 5 +- workspace_tests/src/rt/cmds/diff_cmd.rs | 8 +- workspace_tests/src/rt/cmds/ensure_cmd.rs | 12 +- .../src/rt/cmds/states_discover_cmd.rs | 4 +- workspace_tests/src/rt_model/item_wrapper.rs | 8 +- .../src/rt_model/output/cli_output.rs | 8 +- .../src/rt_model/states_serializer.rs | 4 +- workspace_tests/src/vec_copy_item.rs | 6 +- 93 files changed, 960 insertions(+), 680 deletions(-) diff --git a/crate/cfg/src/accessors/stored.rs b/crate/cfg/src/accessors/stored.rs index 30c3ae3db..852139988 100644 --- a/crate/cfg/src/accessors/stored.rs +++ b/crate/cfg/src/accessors/stored.rs @@ -20,8 +20,8 @@ use serde::Serialize; pub struct Stored<'borrow, ItemIdT, T> { /// ID of the item the state should be retrieved for. item_id: ItemIdT, - /// The borrowed `StatesCurrentStored`. - states_current_stored: Option>, + /// The borrowed `StatesCurrentStored`. + states_current_stored: Option>>, /// Marker. marker: PhantomData, } @@ -47,7 +47,7 @@ where fn borrow(item_id: &'borrow ItemIdT, resources: &'borrow Resources) -> Self { let states_current_stored = resources - .try_borrow::() + .try_borrow::>() .map_err(|borrow_fail| match borrow_fail { e @ BorrowFail::ValueNotFound => e, BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { @@ -70,7 +70,7 @@ impl<'borrow, ItemIdT, T> DataAccess for Stored<'borrow, ItemIdT, T> { Self: Sized, { let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::()); + type_ids.push(TypeId::of::>()); type_ids } @@ -88,7 +88,7 @@ impl<'borrow, ItemIdT, T> DataAccessDyn for Stored<'borrow, ItemIdT, T> { Self: Sized, { let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::()); + type_ids.push(TypeId::of::>()); type_ids } diff --git a/crate/cmd/src/scopes/multi_profile_single_flow.rs b/crate/cmd/src/scopes/multi_profile_single_flow.rs index 764966d0c..b2d07cca2 100644 --- a/crate/cmd/src/scopes/multi_profile_single_flow.rs +++ b/crate/cmd/src/scopes/multi_profile_single_flow.rs @@ -32,7 +32,7 @@ use crate::ctx::CmdCtxTypes; /// | |- 🌊 deploy # ✅ can read `FlowId` /// | | |- 📝 flow_params.yaml # ✅ can read or write `FlowParams` /// | | |- 📋 states_goal.yaml # ✅ can read or write `StatesGoal` -/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` +/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` /// | | /// | |- 🌊 .. # ❌ cannot read or write other `Flow` information /// | @@ -124,7 +124,7 @@ where FlowParams<<::FlowParamsKMaybe as KeyMaybe>::Key>, >, /// Stored current states for each profile for the selected flow. - profile_to_states_current_stored: BTreeMap>, + profile_to_states_current_stored: BTreeMap>>, /// Type registry for each item's [`Params`]`::Spec`. /// /// This is used to deserialize [`ParamsSpecsFile`]. @@ -200,7 +200,8 @@ where FlowParams<<::FlowParamsKMaybe as KeyMaybe>::Key>, >, /// Stored current states for each profile for the selected flow. - pub profile_to_states_current_stored: &'view BTreeMap>, + pub profile_to_states_current_stored: + &'view BTreeMap>>, /// Type registry for each item's [`Params`]`::Spec`. /// /// This is used to deserialize [`ParamsSpecsFile`]. @@ -253,7 +254,7 @@ where <::FlowParamsKMaybe as KeyMaybe>::Key, >, >, - profile_to_states_current_stored: BTreeMap>, + profile_to_states_current_stored: BTreeMap>>, params_specs_type_reg: ParamsSpecsTypeReg, profile_to_params_specs: BTreeMap>, states_type_reg: StatesTypeReg, @@ -413,7 +414,7 @@ where /// flow. pub fn profile_to_states_current_stored( &self, - ) -> &BTreeMap> { + ) -> &BTreeMap>> { &self.profile_to_states_current_stored } diff --git a/crate/cmd/src/scopes/single_profile_single_flow.rs b/crate/cmd/src/scopes/single_profile_single_flow.rs index ea14e9979..0d29c7fcc 100644 --- a/crate/cmd/src/scopes/single_profile_single_flow.rs +++ b/crate/cmd/src/scopes/single_profile_single_flow.rs @@ -31,7 +31,7 @@ use crate::ctx::CmdCtxTypes; /// | |- 🌊 deploy # ✅ can read `FlowId` /// | | |- 📝 flow_params.yaml # ✅ can read or write `FlowParams` /// | | |- 📋 states_goal.yaml # ✅ can read or write `StatesGoal` -/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` +/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` /// | | /// | |- 🌊 .. # ❌ cannot read or write other `Flow` information /// | @@ -133,7 +133,7 @@ where /// | |- 🌊 deploy # ✅ can read `FlowId` /// | | |- 📝 flow_params.yaml # ✅ can read or write `FlowParams` /// | | |- 📋 states_goal.yaml # ✅ can read or write `StatesGoal` -/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` +/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` /// | | /// | |- 🌊 .. # ❌ cannot read or write other `Flow` information /// | diff --git a/crate/cmd_model/src/cmd_block_desc.rs b/crate/cmd_model/src/cmd_block_desc.rs index 8598597b9..b6d6e1f05 100644 --- a/crate/cmd_model/src/cmd_block_desc.rs +++ b/crate/cmd_model/src/cmd_block_desc.rs @@ -43,7 +43,7 @@ impl CmdBlockDesc { } /// Returns the short type names of `CmdBlock::InputT`, e.g. - /// `["States", "States"]`. + /// `["States", "States"]`. /// /// * If `InputT` is the unit struct `()`, this should be empty. /// * If `InputT` is a named struct, this should contain just one `String`. diff --git a/crate/cmd_model/src/cmd_execution_error.rs b/crate/cmd_model/src/cmd_execution_error.rs index f58d7d18e..ac33ab821 100644 --- a/crate/cmd_model/src/cmd_execution_error.rs +++ b/crate/cmd_model/src/cmd_execution_error.rs @@ -12,10 +12,10 @@ use crate::CmdBlockDesc; pub enum CmdExecutionError { /// Error fetching `CmdBlock::InputT` from `resources`. /// - /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, StatesGoal)`, - /// and `states_current` and `states_goal` are inserted individually in - /// `Resources`, then `CmdBlock::input_fetch` should be implemented to call - /// `Resources::remove` for each of them. + /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, + /// StatesGoal)`, and `states_current` and `states_goal` are + /// inserted individually in `Resources`, then `CmdBlock::input_fetch` + /// should be implemented to call `Resources::remove` for each of them. #[error( "Error in `CmdExecution` or `CmdBlock` logic, usually due to incorrect `Resource` insertion or removal." )] @@ -44,23 +44,23 @@ pub enum CmdExecutionError { /// /// ```yaml /// CmdExecution: - /// ExecutionOutcome: (States, States, States) + /// ExecutionOutcome: (States, States, States) /// CmdBlocks: /// - StatesCurrentReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesGoalReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesDiscoverCmdBlock: /// Input: () - /// Outcome: (States, States) + /// Outcome: (States, States) /// - ApplyStateSyncCheckCmdBlock: - /// Input: (States, States, States, States) - /// Outcome: (States, States, States, States) + /// Input: (States, States, States, States) + /// Outcome: (States, States, States, States) /// - ApplyExecCmdBlock: - /// Input: (States, States) - /// Outcome: (States, States, States) + /// Input: (States, States) + /// Outcome: (States, States, States) /// ``` #[cfg(feature = "error_reporting")] #[source_code] diff --git a/crate/cmd_rt/src/cmd_block.rs b/crate/cmd_rt/src/cmd_block.rs index 06abda006..5d46496e1 100644 --- a/crate/cmd_rt/src/cmd_block.rs +++ b/crate/cmd_rt/src/cmd_block.rs @@ -48,7 +48,8 @@ pub trait CmdBlock: Debug { /// /// `CmdBlock` uses the `AppError` and `ParamsKeys` associated type. type CmdCtxTypes: CmdCtxTypesConstrained; - /// Outcome type of the command block, e.g. `(StatesCurrent, StatesGoal)`. + /// Outcome type of the command block, e.g. `(StatesCurrent, + /// StatesGoal)`. type Outcome: Debug + Send + Sync + 'static; /// Input type of the command block, e.g. `StatesCurrent`. type InputT: Resource + 'static; @@ -91,20 +92,20 @@ pub trait CmdBlock: Debug { /// Within the `peace` framework: /// /// ```rust,ignore - /// // type InputT = (StatesCurrent, StatesGoal); + /// // type InputT = (StatesCurrent, StatesGoal); /// - /// vec![tynm::type_name::(), - /// tynm::type_name::()] + /// vec![tynm::type_name::>(), + /// tynm::type_name::>()] /// ``` /// /// Outside the `peace` framework: /// /// ```rust,ignore - /// // type InputT = (StatesCurrent, StatesGoal); + /// // type InputT = (StatesCurrent, StatesGoal); /// /// vec![ - /// peace::cmd_rt::tynm::type_name::(), - /// peace::cmd_rt::tynm::type_name::(), + /// peace::cmd_rt::tynm::type_name::>(), + /// peace::cmd_rt::tynm::type_name::>(), /// ] /// ``` fn input_type_names(&self) -> Vec { @@ -140,20 +141,20 @@ pub trait CmdBlock: Debug { /// Within the `peace` framework: /// /// ```rust,ignore - /// // type Outcome = (StatesCurrent, StatesGoal); + /// // type Outcome = (StatesCurrent, StatesGoal); /// - /// vec![tynm::type_name::(), - /// tynm::type_name::()] + /// vec![tynm::type_name::>(), + /// tynm::type_name::>()] /// ``` /// /// Outside the `peace` framework: /// /// ```rust,ignore - /// // type Outcome = (StatesCurrent, StatesGoal); + /// // type Outcome = (StatesCurrent, StatesGoal); /// /// vec![ - /// peace::cmd_rt::tynm::type_name::(), - /// peace::cmd_rt::tynm::type_name::(), + /// peace::cmd_rt::tynm::type_name::>(), + /// peace::cmd_rt::tynm::type_name::>(), /// ] /// ``` fn outcome_type_names(&self) -> Vec { diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs index 896c6612a..b22e239d2 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs @@ -19,10 +19,10 @@ where { /// Error fetching `CmdBlock::InputT` from `resources`. /// - /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, StatesGoal)`, - /// and `states_current` and `states_goal` are inserted individually in - /// `Resources`, then `CmdBlock::input_fetch` should be implemented to call - /// `Resources::remove` for each of them. + /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, + /// StatesGoal)`, and `states_current` and `states_goal` are + /// inserted individually in `Resources`, then `CmdBlock::input_fetch` + /// should be implemented to call `Resources::remove` for each of them. #[error( "Failed to fetch `{input_name_short}` from `resource`s.", input_name_short = _0.resource_name_short diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs b/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs index e3e1efb29..7d9ace11c 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs @@ -8,7 +8,8 @@ use crate::CmdBlockRt; /// /// * `E`: Automation software error type. /// * `PKeys`: Types of params keys. -/// * `Outcome`: [`CmdBlock`] outcome type, e.g. `(StatesCurrent, StatesGoal)`. +/// * `Outcome`: [`CmdBlock`] outcome type, e.g. `(StatesCurrent, +/// StatesGoal)`. /// /// [`CmdBlock`]: crate::CmdBlock pub type CmdBlockRtBox<'types, CmdCtxTypesT, ExecutionOutcome> = Pin< diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs b/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs index 12fb4483e..0227d04a3 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs @@ -143,8 +143,8 @@ where // If possible, `CmdBlock` outcomes with item errors need to be mapped to // the `CmdExecution` outcome type, so we still return the item errors. // - // e.g. `StatesCurrentMut` should be mapped into `StatesEnsured` when some - // items fail to be ensured. + // e.g. `StatesCurrentMut` should be mapped into `StatesEnsured` when + // some items fail to be ensured. // // Note, when discovering current and goal states for diffing, and an item // error occurs, mapping the partially accumulated `(StatesCurrentMut, diff --git a/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs b/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs index 16d40029d..5a1f59187 100644 --- a/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs +++ b/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs @@ -28,23 +28,23 @@ impl CmdExecutionErrorBuilder { /// /// ```yaml /// CmdExecution: - /// ExecutionOutcome: (States, States, States) + /// ExecutionOutcome: (States, States, States) /// CmdBlocks: /// - StatesCurrentReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesGoalReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesDiscoverCmdBlock: /// Input: () - /// Outcome: (States, States) + /// Outcome: (States, States) /// - ApplyStateSyncCheckCmdBlock: - /// Input: (States, States, States, States) - /// Outcome: (States, States, States, States) + /// Input: (States, States, States, States) + /// Outcome: (States, States, States, States) /// - ApplyExecCmdBlock: - /// Input: (States, States) - /// Outcome: (States, States, States) + /// Input: (States, States) + /// Outcome: (States, States, States) /// ``` pub fn build<'types: 'f, 'f, ExecutionOutcome, CmdCtxTypesT, CmdBlockIterator>( cmd_blocks: CmdBlockIterator, diff --git a/crate/code_gen/src/cmd/impl_build.rs b/crate/code_gen/src/cmd/impl_build.rs index d09d015ec..6147999e8 100644 --- a/crate/code_gen/src/cmd/impl_build.rs +++ b/crate/code_gen/src/cmd/impl_build.rs @@ -649,14 +649,14 @@ fn impl_build_for( // &states_current_file, // ) // .await? - // .map(Into::::into); + // .map(Into::>::into); // // Ok((profile.clone(), states_current_stored)) // }) // .try_collect::< // std::collections::BTreeMap< // peace_core::Profile, - // Option + // Option> // > // >() // .await?; @@ -715,7 +715,7 @@ fn impl_build_for( // &states_current_file, // ) // .await? - // .map(Into::::into); + // .map(Into::>::into); // if let Some(states_current_stored) = states_current_stored { // resources.insert(states_current_stored); // } @@ -1542,7 +1542,7 @@ fn states_and_params_read_and_pg_init(scope: Scope) -> proc_macro2::TokenStream Scope::MultiProfileSingleFlow => { // * Reads previous item params and stores them in a `Map`. // * Reads previously stored current states and stores them in a `Map`. + // StatesCurrentStored>`. // // These are then held in the scope for easy access for consumers. quote! { @@ -1617,14 +1617,14 @@ fn states_and_params_read_and_pg_init(scope: Scope) -> proc_macro2::TokenStream &states_current_file, ) .await? - .map(Into::::into); + .map(Into::>::into); Ok((profile.clone(), states_current_stored)) }) .try_collect::< std::collections::BTreeMap< peace_core::Profile, - Option + Option> > >() .await?; @@ -1701,7 +1701,7 @@ fn states_and_params_read_and_pg_init(scope: Scope) -> proc_macro2::TokenStream &states_current_file, ) .await? - .map(Into::::into); + .map(Into::>::into); if let Some(states_current_stored) = states_current_stored { resources.insert(states_current_stored); } diff --git a/crate/core/src/progress/progress_sender.rs b/crate/core/src/progress/progress_sender.rs index f75c3469e..41194026e 100644 --- a/crate/core/src/progress/progress_sender.rs +++ b/crate/core/src/progress/progress_sender.rs @@ -1,22 +1,19 @@ use tokio::sync::mpsc::Sender; -use crate::{ - progress::{ - CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressUpdate, ProgressUpdateAndId, - }, - ItemIdT, +use crate::progress::{ + CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressUpdate, ProgressUpdateAndId, }; /// Submits progress for an item's `ApplyFns::exec` method. #[derive(Clone, Copy, Debug)] -pub struct ProgressSender<'exec> { +pub struct ProgressSender<'exec, ItemIdT> { /// ID of the item this belongs to. item_id: &'exec ItemIdT, /// Channel sender to send progress updates to. progress_tx: &'exec Sender, } -impl<'exec> ProgressSender<'exec> { +impl<'exec, ItemIdT> ProgressSender<'exec, ItemIdT> { /// Returns a new `ProgressSender`. pub fn new(item_id: &'exec ItemIdT, progress_tx: &'exec Sender) -> Self { Self { diff --git a/crate/core/src/progress/progress_update_and_id.rs b/crate/core/src/progress/progress_update_and_id.rs index 8306f486b..115cf9315 100644 --- a/crate/core/src/progress/progress_update_and_id.rs +++ b/crate/core/src/progress/progress_update_and_id.rs @@ -1,13 +1,10 @@ use serde::{Deserialize, Serialize}; -use crate::{ - progress::{ProgressMsgUpdate, ProgressUpdate}, - ItemIdT, -}; +use crate::progress::{ProgressMsgUpdate, ProgressUpdate}; /// An item ID and its progress update. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct ProgressUpdateAndId { +pub struct ProgressUpdateAndId { /// ID of the item whose progress is updated. pub item_id: ItemIdT, /// Delta update for the progress tracker. diff --git a/crate/params/src/field_wise_spec_rt.rs b/crate/params/src/field_wise_spec_rt.rs index 0a84bcca8..0e81ef302 100644 --- a/crate/params/src/field_wise_spec_rt.rs +++ b/crate/params/src/field_wise_spec_rt.rs @@ -27,14 +27,14 @@ pub trait FieldWiseSpecRt: AnySpecRt { fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result>; /// Resolves the values to construct the item `Params`. /// /// Values that are not present in `Resources` will be `None`. fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result>; } diff --git a/crate/params/src/mapping_fn.rs b/crate/params/src/mapping_fn.rs index 8c4ac9c67..292d9c4b9 100644 --- a/crate/params/src/mapping_fn.rs +++ b/crate/params/src/mapping_fn.rs @@ -25,8 +25,8 @@ pub trait MappingFn: Debug + DataType { fn map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result>; /// Maps data in resources to the output type. /// @@ -40,8 +40,8 @@ pub trait MappingFn: Debug + DataType { fn try_map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError>; /// Returns whether this mapping function actually holds the function logic. /// diff --git a/crate/params/src/mapping_fn_impl.rs b/crate/params/src/mapping_fn_impl.rs index 028c77547..c6d5d862e 100644 --- a/crate/params/src/mapping_fn_impl.rs +++ b/crate/params/src/mapping_fn_impl.rs @@ -115,8 +115,8 @@ macro_rules! impl_mapping_fn_impl { pub fn map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { let fn_map = self.fn_map.as_ref().unwrap_or_else( #[cfg_attr(coverage_nightly, coverage(off))] || { @@ -144,7 +144,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::ApplyDry => { $(arg_resolve!(resources, value_resolution_ctx, ApplyDry, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -152,7 +152,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::Current => { $(arg_resolve!(resources, value_resolution_ctx, Current, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -160,7 +160,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::Goal => { $(arg_resolve!(resources, value_resolution_ctx, Goal, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -168,7 +168,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::Clean => { $(arg_resolve!(resources, value_resolution_ctx, Clean, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -179,8 +179,8 @@ macro_rules! impl_mapping_fn_impl { pub fn try_map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { let fn_map = self.fn_map.as_ref().unwrap_or_else( #[cfg_attr(coverage_nightly, coverage(off))] || { @@ -271,16 +271,16 @@ macro_rules! impl_mapping_fn_impl { fn map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result<::Output, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result<::Output, ParamsResolveError> { MappingFnImpl::::map(self, resources, value_resolution_ctx) } fn try_map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result::Output>, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result::Output>, ParamsResolveError> { MappingFnImpl::::try_map(self, resources, value_resolution_ctx) } @@ -326,13 +326,13 @@ macro_rules! arg_resolve { // by any item, or // * There is a bug in Peace. BorrowFail::ValueNotFound => { - return Err(ParamsResolveError::FromMap { + return Err(ParamsResolveError::FromMap { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); } BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -340,7 +340,7 @@ macro_rules! arg_resolve { }, }, BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -351,7 +351,7 @@ macro_rules! arg_resolve { BorrowedData::Marked(marked_data) => match marked_data.as_ref() { Some(data) => data, None => { - return Err(ParamsResolveError::FromMap { + return Err(ParamsResolveError::FromMap { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -392,7 +392,7 @@ macro_rules! try_arg_resolve { // * There is a bug in Peace. BorrowFail::ValueNotFound => return Ok(None), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -400,7 +400,7 @@ macro_rules! try_arg_resolve { }, }, BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); diff --git a/crate/params/src/params_resolve_error.rs b/crate/params/src/params_resolve_error.rs index 20b6997be..918375ae8 100644 --- a/crate/params/src/params_resolve_error.rs +++ b/crate/params/src/params_resolve_error.rs @@ -6,7 +6,7 @@ use crate::{FieldNameAndType, ValueResolutionCtx}; // struct, enum -- instead of assuming it's always a named fields struct. #[derive(Debug, thiserror::Error)] #[cfg_attr(feature = "error_reporting", derive(miette::Diagnostic))] -pub enum ParamsResolveError { +pub enum ParamsResolveError { /// Failed to resolve a field value from `resources`. #[cfg_attr( feature = "error_reporting", @@ -33,7 +33,7 @@ pub enum ParamsResolveError { .unwrap_or(value_resolution_ctx.params_type_name()))] InMemory { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, }, /// Failed to borrow a field value from `resources`. @@ -64,7 +64,7 @@ pub enum ParamsResolveError { ] InMemoryBorrowConflict { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, }, /// Failed to resolve a from value from `resources`. @@ -88,7 +88,7 @@ pub enum ParamsResolveError { )] FromMap { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, /// Name of the type from which to map the field value from. /// /// Corresponds to `U` in `Fn(&U) -> T`. @@ -112,7 +112,7 @@ pub enum ParamsResolveError { )] FromMapBorrowConflict { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, /// Name of the type from which to map the field value from. /// /// Corresponds to `U` in `Fn(&U) -> T`. diff --git a/crate/params/src/params_spec.rs b/crate/params/src/params_spec.rs index 583112806..b17f1bd09 100644 --- a/crate/params/src/params_spec.rs +++ b/crate/params/src/params_spec.rs @@ -140,18 +140,18 @@ where pub fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { match self { ParamsSpec::Value { value } => Ok(value.clone()), ParamsSpec::Stored | ParamsSpec::InMemory => match resources.try_borrow::() { Ok(value) => Ok((*value).clone()), Err(borrow_fail) => match borrow_fail { - BorrowFail::ValueNotFound => Err(ParamsResolveError::InMemory { + BorrowFail::ValueNotFound => Err(ParamsResolveError::::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::InMemoryBorrowConflict { + Err(ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -167,8 +167,8 @@ where pub fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { match self { ParamsSpec::Value { value } => Ok(T::Partial::from((*value).clone())), ParamsSpec::Stored | ParamsSpec::InMemory => match resources.try_borrow::() { @@ -176,7 +176,7 @@ where Err(borrow_fail) => match borrow_fail { BorrowFail::ValueNotFound => Ok(T::Partial::default()), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::InMemoryBorrowConflict { + Err(ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -268,16 +268,16 @@ where fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { ParamsSpec::::resolve(self, resources, value_resolution_ctx) } fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { ParamsSpec::::resolve_partial(self, resources, value_resolution_ctx) .map(T::try_from) .map(Result::ok) diff --git a/crate/params/src/params_spec_fieldless.rs b/crate/params/src/params_spec_fieldless.rs index f71a8b944..e741e7409 100644 --- a/crate/params/src/params_spec_fieldless.rs +++ b/crate/params/src/params_spec_fieldless.rs @@ -118,19 +118,19 @@ where pub fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { match self { ParamsSpecFieldless::Value { value } => Ok(value.clone()), ParamsSpecFieldless::Stored | ParamsSpecFieldless::InMemory => { match resources.try_borrow::() { Ok(value) => Ok((*value).clone()), Err(borrow_fail) => match borrow_fail { - BorrowFail::ValueNotFound => Err(ParamsResolveError::InMemory { + BorrowFail::ValueNotFound => Err(ParamsResolveError::::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::InMemoryBorrowConflict { + Err(ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -146,8 +146,8 @@ where pub fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { match self { ParamsSpecFieldless::Value { value } => Ok(T::Partial::from((*value).clone())), ParamsSpecFieldless::Stored | ParamsSpecFieldless::InMemory => { @@ -156,7 +156,7 @@ where Err(borrow_fail) => match borrow_fail { BorrowFail::ValueNotFound => Ok(T::Partial::default()), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::InMemoryBorrowConflict { + Err(ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -230,16 +230,16 @@ where fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { ParamsSpecFieldless::::resolve(self, resources, value_resolution_ctx) } fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { ParamsSpecFieldless::::resolve_partial(self, resources, value_resolution_ctx) .map(T::try_from) .map(Result::ok) diff --git a/crate/params/src/params_specs.rs b/crate/params/src/params_specs.rs index 76d3d06ad..0c94e86c4 100644 --- a/crate/params/src/params_specs.rs +++ b/crate/params/src/params_specs.rs @@ -24,11 +24,16 @@ use crate::AnySpecRtBoxed; /// /// The information may not be of the same type across flows, as flows are /// different in what they are doing. -#[derive(Clone, Debug, Default, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct ParamsSpecs(TypeMap); +pub struct ParamsSpecs(TypeMap) +where + ItemIdT: ItemId; -impl ParamsSpecs { +impl ParamsSpecs +where + ItemIdT: ItemId, +{ /// Returns a new `ParamsSpecs` map. pub fn new() -> Self { Self::default() @@ -49,7 +54,19 @@ impl ParamsSpecs { } } -impl Deref for ParamsSpecs { +impl Default for ParamsSpecs +where + ItemIdT: ItemId, +{ + fn default() -> Self { + Self(TypeMap::default()) + } +} + +impl Deref for ParamsSpecs +where + ItemIdT: ItemId, +{ type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -57,13 +74,19 @@ impl Deref for ParamsSpecs { } } -impl DerefMut for ParamsSpecs { +impl DerefMut for ParamsSpecs +where + ItemIdT: ItemId, +{ fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl From> for ParamsSpecs { +impl From> for ParamsSpecs +where + ItemIdT: ItemId, +{ fn from(type_map: TypeMap) -> Self { Self(type_map) } diff --git a/crate/params/src/value_resolution_ctx.rs b/crate/params/src/value_resolution_ctx.rs index f9c753345..d5f0ab320 100644 --- a/crate/params/src/value_resolution_ctx.rs +++ b/crate/params/src/value_resolution_ctx.rs @@ -6,7 +6,7 @@ use crate::{FieldNameAndType, ValueResolutionMode}; /// Collects information about how a value is resolved. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct ValueResolutionCtx { +pub struct ValueResolutionCtx { /// When resolving `Value`s, whether to look up `Current` or /// `Goal`. value_resolution_mode: ValueResolutionMode, @@ -18,7 +18,7 @@ pub struct ValueResolutionCtx { resolution_chain: Vec, } -impl ValueResolutionCtx { +impl ValueResolutionCtx { pub fn new( value_resolution_mode: ValueResolutionMode, item_id: ItemIdT, @@ -59,7 +59,7 @@ impl ValueResolutionCtx { } } -impl fmt::Display for ValueResolutionCtx { +impl fmt::Display for ValueResolutionCtx { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let params_type_name = self.params_type_name(); write!(f, "{params_type_name} {{")?; diff --git a/crate/params/src/value_spec.rs b/crate/params/src/value_spec.rs index 86b042248..e84e28d52 100644 --- a/crate/params/src/value_spec.rs +++ b/crate/params/src/value_spec.rs @@ -116,18 +116,18 @@ where pub fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { match self { ValueSpec::Value { value } => Ok(value.clone()), ValueSpec::Stored | ValueSpec::InMemory => match resources.try_borrow::() { Ok(value) => Ok((*value).clone()), Err(borrow_fail) => match borrow_fail { - BorrowFail::ValueNotFound => Err(ParamsResolveError::InMemory { + BorrowFail::ValueNotFound => Err(ParamsResolveError::::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::InMemoryBorrowConflict { + Err(ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -140,8 +140,8 @@ where pub fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { match self { ValueSpec::Value { value } => Ok(Some((*value).clone())), ValueSpec::Stored | ValueSpec::InMemory => match resources.try_borrow::() { @@ -149,7 +149,7 @@ where Err(borrow_fail) => match borrow_fail { BorrowFail::ValueNotFound => Ok(None), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::InMemoryBorrowConflict { + Err(ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -206,16 +206,16 @@ where fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result> { ValueSpec::::resolve(self, resources, value_resolution_ctx) } fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { ValueSpec::::resolve_partial(self, resources, value_resolution_ctx) } } diff --git a/crate/params/src/value_spec_rt.rs b/crate/params/src/value_spec_rt.rs index b996855ad..7d9142169 100644 --- a/crate/params/src/value_spec_rt.rs +++ b/crate/params/src/value_spec_rt.rs @@ -23,14 +23,14 @@ pub trait ValueSpecRt: AnySpecRt { fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result>; /// Resolves the value from resources, returning `None` if it is not /// present. fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError>; } diff --git a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs index 447eacf24..11bce9943 100644 --- a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs +++ b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs @@ -102,16 +102,16 @@ pub fn impl_field_wise_spec_rt_for_field_wise( fn resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { #resolve_body } fn resolve_partial( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { #resolve_partial_body } } diff --git a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs index 17ae4a88b..8b50af625 100644 --- a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs +++ b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs @@ -23,8 +23,8 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( fn resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { if let Some(params) = self.0.as_ref() { Ok(params.clone()) } else { @@ -32,13 +32,13 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( Ok(t) => Ok((&*t).clone()), Err(borrow_fail) => match borrow_fail { #peace_resources_path::BorrowFail::ValueNotFound => { - Err(#peace_params_path::ParamsResolveError::InMemory { + Err(#peace_params_path::ParamsResolveError::::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }) } #peace_resources_path::BorrowFail::BorrowConflictImm | #peace_resources_path::BorrowFail::BorrowConflictMut => { - Err(#peace_params_path::ParamsResolveError::InMemoryBorrowConflict { + Err(#peace_params_path::ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -50,8 +50,8 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( fn resolve_partial( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { if let Some(params) = self.0.as_ref() { Ok(params.clone().into()) } else { @@ -59,13 +59,13 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( Ok(t) => Ok((&*t).clone().into()), Err(borrow_fail) => match borrow_fail { #peace_resources_path::BorrowFail::ValueNotFound => { - Err(#peace_params_path::ParamsResolveError::InMemory { + Err(#peace_params_path::ParamsResolveError::::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }) } #peace_resources_path::BorrowFail::BorrowConflictImm | #peace_resources_path::BorrowFail::BorrowConflictMut => { - Err(#peace_params_path::ParamsResolveError::InMemoryBorrowConflict { + Err(#peace_params_path::ParamsResolveError::::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } diff --git a/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs b/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs index 3334f67e0..15d0064ea 100644 --- a/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs +++ b/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs @@ -100,16 +100,16 @@ pub fn impl_value_spec_rt_for_field_wise( fn resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { #resolve_body } fn try_resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result, #peace_params_path::ParamsResolveError> { #try_resolve_body } } diff --git a/crate/resources/src/internal/state_diffs_mut.rs b/crate/resources/src/internal/state_diffs_mut.rs index 347769299..f9868946a 100644 --- a/crate/resources/src/internal/state_diffs_mut.rs +++ b/crate/resources/src/internal/state_diffs_mut.rs @@ -14,10 +14,15 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// /// [`StateDiffs`]: crate::StateDiffs /// [`Resources`]: crate::Resources -#[derive(Debug, Default, Serialize)] -pub struct StateDiffsMut(TypeMap); +#[derive(Debug, Serialize)] +pub struct StateDiffsMut(TypeMap) +where + ItemIdT: ItemId; -impl StateDiffsMut { +impl StateDiffsMut +where + ItemIdT: ItemId, +{ /// Returns a new `StateDiffsMut` map. pub fn new() -> Self { Self::default() @@ -37,7 +42,19 @@ impl StateDiffsMut { } } -impl Deref for StateDiffsMut { +impl Default for StateDiffsMut +where + ItemIdT: ItemId, +{ + fn default() -> Self { + Self(TypeMap::default()) + } +} + +impl Deref for StateDiffsMut +where + ItemIdT: ItemId, +{ type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -45,19 +62,28 @@ impl Deref for StateDiffsMut { } } -impl DerefMut for StateDiffsMut { +impl DerefMut for StateDiffsMut +where + ItemIdT: ItemId, +{ fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl From> for StateDiffsMut { +impl From> for StateDiffsMut +where + ItemIdT: ItemId, +{ fn from(type_map: TypeMap) -> Self { Self(type_map) } } -impl Extend<(ItemIdT, BoxDtDisplay)> for StateDiffsMut { +impl Extend<(ItemIdT, BoxDtDisplay)> for StateDiffsMut +where + ItemIdT: ItemId, +{ fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state_diff)| { self.insert_raw(item_id, state_diff); diff --git a/crate/resources/src/internal/states_mut.rs b/crate/resources/src/internal/states_mut.rs index 089ef86ac..befcf571b 100644 --- a/crate/resources/src/internal/states_mut.rs +++ b/crate/resources/src/internal/states_mut.rs @@ -26,9 +26,14 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// [`StatesCurrent`]: crate::StatesCurrent /// [`StatesRw`]: crate::StatesRw #[derive(Debug, Serialize)] -pub struct StatesMut(TypeMap, PhantomData); +pub struct StatesMut(TypeMap, PhantomData) +where + ItemIdT: ItemId; -impl StatesMut { +impl StatesMut +where + ItemIdT: ItemId, +{ /// Returns a new `StatesMut` map. pub fn new() -> Self { Self::default() @@ -48,13 +53,19 @@ impl StatesMut { } } -impl Default for StatesMut { +impl Default for StatesMut +where + ItemIdT: ItemId, +{ fn default() -> Self { Self(TypeMap::default(), PhantomData) } } -impl Deref for StatesMut { +impl Deref for StatesMut +where + ItemIdT: ItemId, +{ type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -62,19 +73,28 @@ impl Deref for StatesMut { } } -impl DerefMut for StatesMut { +impl DerefMut for StatesMut +where + ItemIdT: ItemId, +{ fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl From> for StatesMut { +impl From> for StatesMut +where + ItemIdT: ItemId, +{ fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } -impl Extend<(ItemIdT, BoxDtDisplay)> for StatesMut { +impl Extend<(ItemIdT, BoxDtDisplay)> for StatesMut +where + ItemIdT: ItemId, +{ fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state)| { self.insert_raw(item_id, state); diff --git a/crate/resources/src/states.rs b/crate/resources/src/states.rs index de5249eae..7c0332ae7 100644 --- a/crate/resources/src/states.rs +++ b/crate/resources/src/states.rs @@ -145,12 +145,17 @@ mod states_serde; /// [`flatten()`]: std::option::Option::flatten #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct States( +pub struct States( pub(crate) TypeMap, pub(crate) PhantomData, -); - -impl States { +) +where + ItemIdT: ItemId; + +impl States +where + ItemIdT: ItemId, +{ /// Returns a new `States` map. pub fn new() -> Self { Self::default() @@ -170,7 +175,10 @@ impl States { } } -impl Clone for States { +impl Clone for States +where + ItemIdT: ItemId, +{ fn clone(&self) -> Self { let mut clone = Self(TypeMap::with_capacity_typed(self.0.len()), PhantomData); clone.0.extend( @@ -183,13 +191,19 @@ impl Clone for States { } } -impl Default for States { +impl Default for States +where + ItemIdT: ItemId, +{ fn default() -> Self { Self(TypeMap::default(), PhantomData) } } -impl Deref for States { +impl Deref for States +where + ItemIdT: ItemId, +{ type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -197,20 +211,29 @@ impl Deref for States { } } -impl From> for States { +impl From> for States +where + ItemIdT: ItemId, +{ fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } -impl From> for States { - fn from(states_mut: StatesMut) -> Self { +impl From> for States +where + ItemIdT: ItemId, +{ + fn from(states_mut: StatesMut) -> Self { Self(states_mut.into_inner(), PhantomData) } } #[peace_fmt::async_trait(?Send)] -impl Presentable for States { +impl Presentable for States +where + ItemIdT: ItemId + Presentable, +{ async fn present<'output, PR>(&self, presenter: &mut PR) -> Result<(), PR::Error> where PR: Presenter<'output>, diff --git a/crate/resources/src/states/state_diffs.rs b/crate/resources/src/states/state_diffs.rs index 0bc95c56c..039f5c6ec 100644 --- a/crate/resources/src/states/state_diffs.rs +++ b/crate/resources/src/states/state_diffs.rs @@ -19,10 +19,24 @@ use crate::internal::StateDiffsMut; /// /// [`External`]: peace_cfg::state::External /// [`Resources`]: crate::Resources -#[derive(Debug, Default, Serialize)] -pub struct StateDiffs(TypeMap); +#[derive(Debug, Serialize)] +pub struct StateDiffs(TypeMap) +where + ItemIdT: ItemId; -impl StateDiffs { +impl Default for StateDiffs +where + ItemIdT: ItemId, +{ + fn default() -> Self { + Self(TypeMap::::default()) + } +} + +impl StateDiffs +where + ItemIdT: ItemId, +{ /// Returns a new `StateDiffs` map. pub fn new() -> Self { Self::default() @@ -42,7 +56,10 @@ impl StateDiffs { } } -impl Deref for StateDiffs { +impl Deref for StateDiffs +where + ItemIdT: ItemId, +{ type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -50,20 +67,29 @@ impl Deref for StateDiffs { } } -impl From> for StateDiffs { +impl From> for StateDiffs +where + ItemIdT: ItemId, +{ fn from(type_map: TypeMap) -> Self { Self(type_map) } } -impl From for StateDiffs { - fn from(state_diffs_mut: StateDiffsMut) -> Self { +impl From> for StateDiffs +where + ItemIdT: ItemId, +{ + fn from(state_diffs_mut: StateDiffsMut) -> Self { Self(state_diffs_mut.into_inner()) } } #[peace_fmt::async_trait(?Send)] -impl Presentable for StateDiffs { +impl Presentable for StateDiffs +where + ItemIdT: ItemId + Presentable, +{ async fn present<'output, PR>(&self, presenter: &mut PR) -> Result<(), PR::Error> where PR: Presenter<'output>, diff --git a/crate/resources/src/states/states_clean.rs b/crate/resources/src/states/states_clean.rs index e619b2a3c..174511867 100644 --- a/crate/resources/src/states/states_clean.rs +++ b/crate/resources/src/states/states_clean.rs @@ -13,4 +13,4 @@ use crate::states::{ts::Clean, States}; /// /// You may reference [`StatesClean`] after `CleanCmd::exec` has been run, /// unless it is the `ExecutionOutcome`. -pub type StatesClean = States; +pub type StatesClean = States; diff --git a/crate/resources/src/states/states_cleaned.rs b/crate/resources/src/states/states_cleaned.rs index 26b13e4ce..b3b3774b5 100644 --- a/crate/resources/src/states/states_cleaned.rs +++ b/crate/resources/src/states/states_cleaned.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ts::Cleaned, States, StatesCurrent}; /// Cleaned `State`s for all `Item`s. `TypeMap` newtype. @@ -14,10 +16,13 @@ use crate::states::{ts::Cleaned, States, StatesCurrent}; /// /// You may reference [`StatesCleaned`] after `CleanCmd::exec` has been run, /// unless it is the `ExecutionOutcome`. -pub type StatesCleaned = States; +pub type StatesCleaned = States; -impl From for StatesCleaned { - fn from(states: StatesCurrent) -> Self { +impl From> for StatesCleaned +where + ItemIdT: ItemId, +{ + fn from(states: StatesCurrent) -> Self { Self(states.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_cleaned_dry.rs b/crate/resources/src/states/states_cleaned_dry.rs index 97f235eed..0a4c0d643 100644 --- a/crate/resources/src/states/states_cleaned_dry.rs +++ b/crate/resources/src/states/states_cleaned_dry.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ts::CleanedDry, States, StatesCurrent}; /// Dry-run ensured `State`s for all `Item`s. @@ -9,14 +11,17 @@ use crate::states::{ts::CleanedDry, States, StatesCurrent}; /// /// # Implementors /// -/// You may reference [`StatesCleanedDry`] after `CleanCmd::exec_dry` has been -/// run. +/// You may reference [`StatesCleanedDry`] after `CleanCmd::exec_dry` +/// has been run. /// /// [`Data`]: peace_data::Data -pub type StatesCleanedDry = States; +pub type StatesCleanedDry = States; -impl From for StatesCleanedDry { - fn from(states: StatesCurrent) -> Self { +impl From> for StatesCleanedDry +where + ItemIdT: ItemId, +{ + fn from(states: StatesCurrent) -> Self { Self(states.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_current.rs b/crate/resources/src/states/states_current.rs index 57788c3ad..d891b7e4d 100644 --- a/crate/resources/src/states/states_current.rs +++ b/crate/resources/src/states/states_current.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ ts::{Current, CurrentStored}, States, @@ -9,8 +11,8 @@ use crate::states::{ /// /// This is strictly only present when the [`States`] are discovered in the /// current execution. `States` read from the [`StatesCurrentFile`] are -/// inserted into [`Resources`] as [`StatesCurrentStored`], as those discovered -/// states may be out of date with the actual. +/// inserted into [`Resources`] as [`StatesCurrentStored`], as those +/// discovered states may be out of date with the actual. /// /// # Implementors /// @@ -47,11 +49,14 @@ use crate::states::{ /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources /// [`StatesCurrentFile`] crate::paths::StatesCurrentFile -/// [`StatesCurrentStored`]: crate::states::StatesCurrentStored -pub type StatesCurrent = States; +/// [`StatesCurrentStored`]: crate::states::StatesCurrentStored +pub type StatesCurrent = States; -impl From> for States { - fn from(states_current_stored: States) -> Self { +impl From> for States +where + ItemIdT: ItemId, +{ + fn from(states_current_stored: States) -> Self { let States(type_map, PhantomData) = states_current_stored; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_current_stored.rs b/crate/resources/src/states/states_current_stored.rs index 5b3b8f5a8..a0aa23b3f 100644 --- a/crate/resources/src/states/states_current_stored.rs +++ b/crate/resources/src/states/states_current_stored.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ ts::{Current, CurrentStored}, States, @@ -45,17 +47,20 @@ use crate::states::{ /// } /// ``` /// -/// You may reference [`StatesCurrentStored`] in `ApplyFns::Data` for reading. -/// It is not mutable as `StatesCurrentStored` must remain unchanged so that all -/// `Item`s operate over consistent data. +/// You may reference [`StatesCurrentStored`] in `ApplyFns::Data` for +/// reading. It is not mutable as `StatesCurrentStored` must remain +/// unchanged so that all `Item`s operate over consistent data. /// /// [`StatesCurrentFile`]: crate::paths::StatesCurrentFile /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources -pub type StatesCurrentStored = States; +pub type StatesCurrentStored = States; -impl From> for States { - fn from(states_current: States) -> Self { +impl From> for States +where + ItemIdT: ItemId, +{ + fn from(states_current: States) -> Self { let States(type_map, PhantomData) = states_current; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_ensured.rs b/crate/resources/src/states/states_ensured.rs index c97ef2545..978a32995 100644 --- a/crate/resources/src/states/states_ensured.rs +++ b/crate/resources/src/states/states_ensured.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ts::Ensured, States, StatesCurrent}; /// Ensured `State`s for all `Item`s. `TypeMap` newtype. @@ -8,13 +10,17 @@ use crate::states::{ts::Ensured, States, StatesCurrent}; /// /// # Implementors /// -/// You may reference [`StatesEnsured`] after `EnsureCmd::exec` has been run. +/// You may reference [`StatesEnsured`] after `EnsureCmd::exec` has +/// been run. /// /// [`Data`]: peace_data::Data -pub type StatesEnsured = States; +pub type StatesEnsured = States; -impl From for StatesEnsured { - fn from(states_current: StatesCurrent) -> Self { +impl From> for StatesEnsured +where + ItemIdT: ItemId, +{ + fn from(states_current: StatesCurrent) -> Self { Self(states_current.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_ensured_dry.rs b/crate/resources/src/states/states_ensured_dry.rs index af7ed3307..1450d30e8 100644 --- a/crate/resources/src/states/states_ensured_dry.rs +++ b/crate/resources/src/states/states_ensured_dry.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ts::EnsuredDry, States, StatesCurrent}; /// Dry-run ensured `State`s for all `Item`s. @@ -9,14 +11,17 @@ use crate::states::{ts::EnsuredDry, States, StatesCurrent}; /// /// # Implementors /// -/// You may reference [`StatesEnsuredDry`] after `EnsureCmd::exec_dry` has been -/// run. +/// You may reference [`StatesEnsuredDry`] after `EnsureCmd::exec_dry` +/// has been run. /// /// [`Data`]: peace_data::Data -pub type StatesEnsuredDry = States; +pub type StatesEnsuredDry = States; -impl From for StatesEnsuredDry { - fn from(states_current: StatesCurrent) -> Self { +impl From> for StatesEnsuredDry +where + ItemIdT: ItemId, +{ + fn from(states_current: StatesCurrent) -> Self { Self(states_current.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_goal.rs b/crate/resources/src/states/states_goal.rs index e5f0ef8f3..e893606a0 100644 --- a/crate/resources/src/states/states_goal.rs +++ b/crate/resources/src/states/states_goal.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ ts::{Goal, GoalStored}, States, @@ -45,10 +47,13 @@ use crate::states::{ /// /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources -pub type StatesGoal = States; +pub type StatesGoal = States; -impl From> for States { - fn from(states_goal_stored: States) -> Self { +impl From> for States +where + ItemIdT: ItemId, +{ + fn from(states_goal_stored: States) -> Self { let States(type_map, PhantomData) = states_goal_stored; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_goal_stored.rs b/crate/resources/src/states/states_goal_stored.rs index 4e366efa0..f6a84522c 100644 --- a/crate/resources/src/states/states_goal_stored.rs +++ b/crate/resources/src/states/states_goal_stored.rs @@ -1,5 +1,7 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ ts::{Goal, GoalStored}, States, @@ -21,10 +23,13 @@ use crate::states::{ /// [`StatesGoalFile`]: crate::paths::StatesGoalFile /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources -pub type StatesGoalStored = States; +pub type StatesGoalStored = States; -impl From> for States { - fn from(states_goal: States) -> Self { +impl From> for States +where + ItemIdT: ItemId, +{ + fn from(states_goal: States) -> Self { let States(type_map, PhantomData) = states_goal; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_previous.rs b/crate/resources/src/states/states_previous.rs index 35185845c..830cb7638 100644 --- a/crate/resources/src/states/states_previous.rs +++ b/crate/resources/src/states/states_previous.rs @@ -1,15 +1,20 @@ use std::marker::PhantomData; +use peace_core::ItemId; + use crate::states::{ts::Previous, States, StatesCurrent}; /// Previous `State`s for all `Item`s. /// /// This is present when an `ApplyCmd` (`EnsureCmd` or `CleanCmd`) is run, /// whereby the current states have changed to the newly ensured states. -pub type StatesPrevious = States; +pub type StatesPrevious = States; -impl From for StatesPrevious { - fn from(states_current: StatesCurrent) -> Self { +impl From> for StatesPrevious +where + ItemIdT: ItemId, +{ + fn from(states_current: StatesCurrent) -> Self { Self(states_current.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_serde.rs b/crate/resources/src/states/states_serde.rs index c5aea647b..c3c7e1f30 100644 --- a/crate/resources/src/states/states_serde.rs +++ b/crate/resources/src/states/states_serde.rs @@ -28,12 +28,16 @@ use type_reg::{ /// [`FromIterator::<(ItemIdT, Option)>::from_iter`]: std::iter::FromIterator #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct StatesSerde(TypeMapOpt>) +pub struct StatesSerde( + TypeMapOpt>, +) where + ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq; -impl StatesSerde +impl StatesSerde where + ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { /// Creates an empty `StatesSerde` map with the specified capacity. @@ -50,8 +54,9 @@ where } } -impl Clone for StatesSerde +impl Clone for StatesSerde where + ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { fn clone(&self) -> Self { @@ -66,8 +71,9 @@ where } } -impl Deref for StatesSerde +impl Deref for StatesSerde where + ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { type Target = TypeMapOpt>; @@ -77,8 +83,9 @@ where } } -impl FromIterator<(ItemIdT, Option)> for StatesSerde +impl FromIterator<(ItemIdT, Option)> for StatesSerde where + ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { fn from_iter)>>(iter: T) -> Self { @@ -92,9 +99,10 @@ where } } -impl From>> - for StatesSerde +impl From>> + for StatesSerde where + ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { fn from(type_map_opt: TypeMapOpt>) -> Self { diff --git a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs index 0e776cce6..9f1dda80c 100644 --- a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs @@ -324,8 +324,8 @@ where mut states_target_mut: StatesMut, ) -> Result< ( - States, - States, + States, + States, IndexMap::AppError>, ), ::AppError, @@ -427,24 +427,28 @@ where StatesTs: StatesTsApplyExt + Debug + Send + Sync + 'static, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (StatesCurrent, States); - type Outcome = (StatesPrevious, States, States); + type InputT = (StatesCurrent, States); + type Outcome = ( + StatesPrevious, + States, + States, + ); fn input_fetch( &self, resources: &mut Resources, ) -> Result { - let states_current = resources.try_remove::()?; + let states_current = resources.try_remove::>()?; - let states_target = resources.try_remove::>()?; + let states_target = resources.try_remove::>()?; Ok((states_current, states_target)) } fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -457,9 +461,9 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -474,7 +478,7 @@ where > { let (states_current, states_target) = input; let (states_previous, states_applied_mut, states_target_mut) = { - let states_previous = StatesPrevious::from(states_current.clone()); + let states_previous = StatesPrevious::::from(states_current.clone()); // `Ensured`, `EnsuredDry`, `Cleaned`, `CleanedDry` states start as the current // state, and are altered. let states_applied_mut = diff --git a/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs b/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs index 98d5a52c2..ae9ac4edf 100644 --- a/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs @@ -124,8 +124,8 @@ where { fn items_state_stored_stale( cmd_view: &SingleProfileSingleFlowView<'_, CmdCtxTypesT>, - states_stored: &States, - states_discovered: &States, + states_stored: &States, + states_discovered: &States, #[cfg(feature = "output_progress")] progress_tx: &Sender, ) -> Result::AppError> { let items_state_stored_stale = cmd_view.flow.graph().iter_insertion().try_fold( @@ -262,7 +262,7 @@ where CmdCtxTypesT: CmdCtxTypesConstrained, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (StatesCurrentStored, StatesCurrent); + type InputT = (StatesCurrentStored, StatesCurrent); type Outcome = Self::InputT; fn input_fetch( @@ -274,8 +274,8 @@ where fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -287,8 +287,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -336,7 +336,7 @@ where CmdCtxTypesT: CmdCtxTypesConstrained, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (StatesGoalStored, StatesGoal); + type InputT = (StatesGoalStored, StatesGoal); type Outcome = Self::InputT; fn input_fetch( @@ -348,8 +348,8 @@ where fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -361,8 +361,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -412,10 +412,10 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = ( - StatesCurrentStored, - StatesCurrent, - StatesGoalStored, - StatesGoal, + StatesCurrentStored, + StatesCurrent, + StatesGoalStored, + StatesGoal, ); type Outcome = Self::InputT; @@ -436,10 +436,10 @@ where fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -453,10 +453,10 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -548,18 +548,18 @@ enum OutcomeResult { fn input_fetch_current( resources: &mut Resources, -) -> Result<(StatesCurrentStored, StatesCurrent), ResourceFetchError> { - let states_current_stored = resources.try_remove::()?; - let states_current = resources.try_remove::()?; +) -> Result<(StatesCurrentStored, StatesCurrent), ResourceFetchError> { + let states_current_stored = resources.try_remove::>()?; + let states_current = resources.try_remove::>()?; Ok((states_current_stored, states_current)) } fn input_fetch_goal( resources: &mut Resources, -) -> Result<(StatesGoalStored, StatesGoal), ResourceFetchError> { - let states_goal_stored = resources.try_remove::()?; - let states_goal = resources.try_remove::()?; +) -> Result<(StatesGoalStored, StatesGoal), ResourceFetchError> { + let states_goal_stored = resources.try_remove::>()?; + let states_goal = resources.try_remove::>()?; Ok((states_goal_stored, states_goal)) } diff --git a/crate/rt/src/cmd_blocks/diff_cmd_block.rs b/crate/rt/src/cmd_blocks/diff_cmd_block.rs index c6e656a9f..213857ab8 100644 --- a/crate/rt/src/cmd_blocks/diff_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/diff_cmd_block.rs @@ -119,23 +119,23 @@ where StatesTs1: Debug + Send + Sync + 'static, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (States, States); + type InputT = (States, States); type Outcome = (StateDiffs, Self::InputT); fn input_fetch( &self, resources: &mut Resources, ) -> Result { - let states_ts0 = resources.try_remove::>()?; - let states_ts1 = resources.try_remove::>()?; + let states_ts0 = resources.try_remove::>()?; + let states_ts1 = resources.try_remove::>()?; Ok((states_ts0, states_ts1)) } fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -149,8 +149,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ tynm::type_name::(), - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } diff --git a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs index 0c399b29c..96c92d44e 100644 --- a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs @@ -20,7 +20,7 @@ cfg_if::cfg_if! { } } -/// Reads [`StatesCurrentStored`]s from storage. +/// Reads [`StatesCurrentStored`]s from storage. /// /// Either [`StatesDiscoverCmdBlock::current`] or /// [`StatesDiscoverCmdBlock::current_and_goal`] must have run prior to this @@ -42,7 +42,8 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, states_type_reg: &TypeReg, - ) -> Result::AppError> { + ) -> Result, ::AppError> + { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); let storage = resources.borrow::(); @@ -79,7 +80,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = StatesCurrentStored; + type Outcome = StatesCurrentStored; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) diff --git a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs index 3a4703f8b..d0746954d 100644 --- a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs @@ -264,7 +264,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = States; + type Outcome = States; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) @@ -352,7 +352,7 @@ where mut states_current_mut: StatesMut, ) -> Result< ( - States, + States, IndexMap::AppError>, ), ::AppError, @@ -407,7 +407,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = States; + type Outcome = States; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) @@ -495,7 +495,7 @@ where mut states_goal_mut: StatesMut, ) -> Result< ( - States, + States, IndexMap::AppError>, ), ::AppError, @@ -550,7 +550,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = (States, States); + type Outcome = (States, States); fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) @@ -568,8 +568,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::(), - tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -654,8 +654,8 @@ where mut states_goal_mut: StatesMut, ) -> Result< ( - States, - States, + States, + States, IndexMap::AppError>, ), ::AppError, diff --git a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs index bbd6cad9d..c619a3e3e 100644 --- a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs @@ -20,7 +20,7 @@ cfg_if::cfg_if! { } } -/// Reads [`StatesGoalStored`]s from storage. +/// Reads [`StatesGoalStored`]s from storage. /// /// Either [`StatesDiscoverCmdBlock::goal`] or /// [`StatesDiscoverCmdBlock::current_and_goal`] must have run prior to this @@ -42,7 +42,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, states_type_reg: &TypeReg, - ) -> Result::AppError> { + ) -> Result, ::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); let storage = resources.borrow::(); @@ -79,7 +79,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = StatesGoalStored; + type Outcome = StatesGoalStored; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) diff --git a/crate/rt/src/cmds/clean_cmd.rs b/crate/rt/src/cmds/clean_cmd.rs index df42be203..451c73cab 100644 --- a/crate/rt/src/cmds/clean_cmd.rs +++ b/crate/rt/src/cmds/clean_cmd.rs @@ -63,7 +63,7 @@ where pub async fn exec_dry<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -82,7 +82,7 @@ where cmd_ctx: &mut CmdCtx>, apply_stored_state_sync: ApplyStoredStateSync, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -97,7 +97,7 @@ where cmd_ctx .view() .resources - .insert::(states_previous); + .insert::>(states_previous); states_cleaned } @@ -182,7 +182,7 @@ where let (states_previous, states_cleaned) = *states_previous_and_cleaned; Self::serialize_current(item_graph, resources, &states_cleaned).await?; - resources.insert::(states_previous); + resources.insert::>(states_previous); Ok(states_cleaned) } @@ -250,8 +250,8 @@ where }, )) .with_execution_outcome_fetch(|resources| { - let states_previous = resources.try_remove::(); - let states_cleaned = resources.try_remove::>(); + let states_previous = resources.try_remove::>(); + let states_cleaned = resources.try_remove::>(); states_previous.ok().zip(states_cleaned.ok()).map( |(states_previous, states_cleaned)| { @@ -315,5 +315,5 @@ enum CleanExecChange { /// /// This variant is used for both partial and complete execution, as long as /// some state was altered. - Some(Box<(StatesPrevious, States)>), + Some(Box<(StatesPrevious, States)>), } diff --git a/crate/rt/src/cmds/ensure_cmd.rs b/crate/rt/src/cmds/ensure_cmd.rs index 213612f02..69e3783c4 100644 --- a/crate/rt/src/cmds/ensure_cmd.rs +++ b/crate/rt/src/cmds/ensure_cmd.rs @@ -55,7 +55,7 @@ where pub async fn exec_dry<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -74,7 +74,7 @@ where cmd_ctx: &mut CmdCtx>, apply_stored_state_sync: ApplyStoredStateSync, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -89,7 +89,7 @@ where cmd_ctx .view() .resources - .insert::(states_previous); + .insert::>(states_previous); states_applied_dry } @@ -124,7 +124,7 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -143,7 +143,7 @@ where cmd_ctx: &mut CmdCtx>, apply_stored_state_sync: ApplyStoredStateSync, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -167,7 +167,7 @@ where Self::serialize_current(item_graph, resources, &states_applied).await?; Self::serialize_goal(item_graph, resources, &states_goal).await?; - resources.insert::(states_previous); + resources.insert::>(states_previous); Ok(states_applied) } @@ -181,7 +181,7 @@ where /// Conditionally runs [`ApplyFns`]`::`[`exec`] for each [`Item`]. /// /// Same as [`Self::exec`], but does not change the type state, and returns - /// [`StatesEnsured`]. + /// [`StatesEnsured`]. /// /// [`exec`]: peace_cfg::ApplyFns::exec /// [`Item`]: peace_cfg::Item @@ -241,9 +241,9 @@ where .with_cmd_block(CmdBlockWrapper::new( ApplyExecCmdBlock::::new(), |(states_previous, states_applied, states_target): ( - StatesPrevious, - States, - States, + StatesPrevious, + States, + States, )| { EnsureExecChange::Some(Box::new(( states_previous, @@ -253,9 +253,9 @@ where }, )) .with_execution_outcome_fetch(|resources| { - let states_previous = resources.try_remove::(); - let states_applied = resources.try_remove::>(); - let states_goal = resources.try_remove::(); + let states_previous = resources.try_remove::>(); + let states_applied = resources.try_remove::>(); + let states_goal = resources.try_remove::>(); if let Some(((states_previous, states_applied), states_goal)) = states_previous .ok() @@ -294,7 +294,7 @@ where async fn serialize_current( item_graph: &ItemGraph<::AppError>, resources: &Resources, - states_applied: &StatesEnsured, + states_applied: &StatesEnsured, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; @@ -314,7 +314,7 @@ where async fn serialize_goal( item_graph: &ItemGraph<::AppError>, resources: &Resources, - states_goal: &StatesGoal, + states_goal: &StatesGoal, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; @@ -345,5 +345,11 @@ enum EnsureExecChange { /// /// This variant is used for both partial and complete execution, as long as /// some state was altered. - Some(Box<(StatesPrevious, States, StatesGoal)>), + Some( + Box<( + StatesPrevious, + States, + StatesGoal, + )>, + ), } diff --git a/crate/rt/src/cmds/states_current_read_cmd.rs b/crate/rt/src/cmds/states_current_read_cmd.rs index 7768dec8b..e01fbde92 100644 --- a/crate/rt/src/cmds/states_current_read_cmd.rs +++ b/crate/rt/src/cmds/states_current_read_cmd.rs @@ -10,7 +10,7 @@ use peace_resources::states::StatesCurrentStored; use crate::cmd_blocks::StatesCurrentReadCmdBlock; -/// Reads [`StatesCurrentStored`]s from storage. +/// Reads [`StatesCurrentStored`]s from storage. #[derive(Debug)] pub struct StatesCurrentReadCmd(PhantomData); @@ -18,27 +18,30 @@ impl StatesCurrentReadCmd where CmdCtxTypesT: CmdCtxTypesConstrained, { - /// Reads [`StatesCurrentStored`]s from storage. + /// Reads [`StatesCurrentStored`]s from storage. /// - /// Either [`StatesCurrentStoredDiscoverCmd`] or [`StatesDiscoverCmd`] must - /// have run prior to this command to read the state. + /// Either [`StatesCurrentStoredDiscoverCmd`] or + /// [`StatesDiscoverCmd`] must have run prior to this command to read + /// the state. /// - /// [`StatesCurrentStoredDiscoverCmd`]: crate::StatesCurrentStoredDiscoverCmd + /// [`StatesCurrentStoredDiscoverCmd`]: crate::StatesCurrentStoredDiscoverCmd /// [`StatesDiscoverCmd`]: crate::StatesDiscoverCmd pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome< + StatesCurrentStored, + ::AppError, + >, ::AppError, > where CmdCtxTypesT: 'ctx, { - let cmd_execution_builder = CmdExecution::::builder() - .with_cmd_block(CmdBlockWrapper::new( - StatesCurrentReadCmdBlock::new(), - std::convert::identity, - )); + let cmd_execution_builder = + CmdExecution::, _>::builder().with_cmd_block( + CmdBlockWrapper::new(StatesCurrentReadCmdBlock::new(), std::convert::identity), + ); #[cfg(feature = "output_progress")] let cmd_execution_builder = cmd_execution_builder.with_progress_render_enabled(false); diff --git a/crate/rt/src/cmds/states_current_stored_display_cmd.rs b/crate/rt/src/cmds/states_current_stored_display_cmd.rs index 4757ab742..90ef0934f 100644 --- a/crate/rt/src/cmds/states_current_stored_display_cmd.rs +++ b/crate/rt/src/cmds/states_current_stored_display_cmd.rs @@ -18,7 +18,7 @@ impl StatesCurrentStoredDisplayCmd where CmdCtxTypesT: CmdCtxTypesConstrained, { - /// Displays [`StatesCurrentStored`]s from storage. + /// Displays [`StatesCurrentStored`]s from storage. /// /// [`StatesDiscoverCmd`] must have run prior to this command to read the /// state. @@ -27,7 +27,10 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome< + StatesCurrentStored, + ::AppError, + >, ::AppError, > where diff --git a/crate/rt/src/cmds/states_discover_cmd.rs b/crate/rt/src/cmds/states_discover_cmd.rs index a437d9f6f..32ce0b3f9 100644 --- a/crate/rt/src/cmds/states_discover_cmd.rs +++ b/crate/rt/src/cmds/states_discover_cmd.rs @@ -49,7 +49,7 @@ where pub async fn current<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -76,13 +76,13 @@ where cmd_ctx: &mut CmdCtx>, serialize_to_storage: bool, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let mut cmd_execution = CmdExecution::::builder() + let mut cmd_execution = CmdExecution::, _>::builder() .with_cmd_block(CmdBlockWrapper::new( #[cfg(not(feature = "output_progress"))] StatesDiscoverCmdBlock::current(), @@ -129,7 +129,7 @@ where pub async fn goal<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where @@ -156,13 +156,13 @@ where cmd_ctx: &mut CmdCtx>, serialize_to_storage: bool, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let mut cmd_execution = CmdExecution::::builder() + let mut cmd_execution = CmdExecution::, _>::builder() .with_cmd_block(CmdBlockWrapper::new( #[cfg(not(feature = "output_progress"))] StatesDiscoverCmdBlock::goal(), @@ -218,7 +218,10 @@ where pub async fn current_and_goal<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome<(StatesCurrent, StatesGoal), ::AppError>, + CmdOutcome< + (StatesCurrent, StatesGoal), + ::AppError, + >, ::AppError, > where @@ -247,34 +250,38 @@ where cmd_ctx: &mut CmdCtx>, serialize_to_storage: bool, ) -> Result< - CmdOutcome<(StatesCurrent, StatesGoal), ::AppError>, + CmdOutcome< + (StatesCurrent, StatesGoal), + ::AppError, + >, ::AppError, > where CmdCtxTypesT: 'ctx, { - let mut cmd_execution = CmdExecution::<(StatesCurrent, StatesGoal), _>::builder() - .with_cmd_block(CmdBlockWrapper::new( - #[cfg(not(feature = "output_progress"))] - StatesDiscoverCmdBlock::current_and_goal(), - #[cfg(feature = "output_progress")] - StatesDiscoverCmdBlock::current_and_goal().progress_complete_on_success(), - |states_current_and_goal_mut| { - let (states_current_mut, states_goal_mut) = states_current_and_goal_mut; - - ( - StatesCurrent::from(states_current_mut), - StatesGoal::from(states_goal_mut), - ) - }, - )) - .with_execution_outcome_fetch(|resources| { - let states_current = resources.try_remove::(); - let states_goal = resources.try_remove::(); - - states_current.ok().zip(states_goal.ok()) - }) - .build(); + let mut cmd_execution = + CmdExecution::<(StatesCurrent, StatesGoal), _>::builder() + .with_cmd_block(CmdBlockWrapper::new( + #[cfg(not(feature = "output_progress"))] + StatesDiscoverCmdBlock::current_and_goal(), + #[cfg(feature = "output_progress")] + StatesDiscoverCmdBlock::current_and_goal().progress_complete_on_success(), + |states_current_and_goal_mut| { + let (states_current_mut, states_goal_mut) = states_current_and_goal_mut; + + ( + StatesCurrent::from(states_current_mut), + StatesGoal::from(states_goal_mut), + ) + }, + )) + .with_execution_outcome_fetch(|resources| { + let states_current = resources.try_remove::>(); + let states_goal = resources.try_remove::>(); + + states_current.ok().zip(states_goal.ok()) + }) + .build(); let cmd_outcome = cmd_execution.exec(cmd_ctx).await?; @@ -297,7 +304,7 @@ where async fn serialize_current( item_graph: &ItemGraph<::AppError>, resources: &mut Resources, - states_current: &StatesCurrent, + states_current: &StatesCurrent, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; @@ -319,7 +326,7 @@ where async fn serialize_goal( item_graph: &ItemGraph<::AppError>, resources: &mut Resources, - states_goal: &StatesGoal, + states_goal: &StatesGoal, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; diff --git a/crate/rt/src/cmds/states_goal_display_cmd.rs b/crate/rt/src/cmds/states_goal_display_cmd.rs index 9388d2493..0eda48023 100644 --- a/crate/rt/src/cmds/states_goal_display_cmd.rs +++ b/crate/rt/src/cmds/states_goal_display_cmd.rs @@ -28,7 +28,7 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where diff --git a/crate/rt/src/cmds/states_goal_read_cmd.rs b/crate/rt/src/cmds/states_goal_read_cmd.rs index 30315d534..33776ed65 100644 --- a/crate/rt/src/cmds/states_goal_read_cmd.rs +++ b/crate/rt/src/cmds/states_goal_read_cmd.rs @@ -10,7 +10,7 @@ use peace_resources::states::StatesGoalStored; use crate::cmd_blocks::StatesGoalReadCmdBlock; -/// Reads [`StatesGoalStored`]s from storage. +/// Reads [`StatesGoalStored`]s from storage. #[derive(Debug)] pub struct StatesGoalReadCmd(PhantomData); @@ -18,7 +18,7 @@ impl StatesGoalReadCmd where CmdCtxTypesT: CmdCtxTypesConstrained, { - /// Reads [`StatesGoalStored`]s from storage. + /// Reads [`StatesGoalStored`]s from storage. /// /// [`StatesDiscoverCmd`] must have run prior to this command to read the /// state. @@ -27,15 +27,16 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome::AppError>, + CmdOutcome, ::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let cmd_execution_builder = CmdExecution::::builder().with_cmd_block( - CmdBlockWrapper::new(StatesGoalReadCmdBlock::new(), std::convert::identity), - ); + let cmd_execution_builder = + CmdExecution::, _>::builder().with_cmd_block( + CmdBlockWrapper::new(StatesGoalReadCmdBlock::new(), std::convert::identity), + ); #[cfg(feature = "output_progress")] let cmd_execution_builder = cmd_execution_builder.with_progress_render_enabled(false); diff --git a/crate/rt_model/src/item_graph.rs b/crate/rt_model/src/item_graph.rs index 3af8c64de..f0429a6e1 100644 --- a/crate/rt_model/src/item_graph.rs +++ b/crate/rt_model/src/item_graph.rs @@ -43,7 +43,10 @@ impl ItemGraph { /// /// This will contain an entry for all items, in order of flow item /// insertion, whether or not a state exists in the provided `states` map. - pub fn states_serde(&self, states: &States) -> StatesSerde + pub fn states_serde( + &self, + states: &States, + ) -> StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, E: 'static, @@ -75,7 +78,7 @@ impl From>> for ItemGraph { } } -impl<'graph, ValueT, E> From<&'graph ItemGraph> for StatesSerde +impl<'graph, ValueT, E> From<&'graph ItemGraph> for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, E: 'static, diff --git a/crate/rt_model/src/item_rt.rs b/crate/rt_model/src/item_rt.rs index 294d29d33..80222dd85 100644 --- a/crate/rt_model/src/item_rt.rs +++ b/crate/rt_model/src/item_rt.rs @@ -199,7 +199,7 @@ pub trait ItemRt: /// [`ApplyFns::check`]: peace_cfg::Item::ApplyFns async fn clean_prepare( &self, - states_current: &StatesCurrent, + states_current: &StatesCurrent, params_specs: &ParamsSpecs, resources: &Resources, ) -> Result diff --git a/crate/rt_model/src/item_wrapper.rs b/crate/rt_model/src/item_wrapper.rs index d623e1a7b..82b8cd0bb 100644 --- a/crate/rt_model/src/item_wrapper.rs +++ b/crate/rt_model/src/item_wrapper.rs @@ -82,14 +82,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Clean, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); I::state_clean(¶ms_partial, data).await? @@ -113,14 +113,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); I::try_state_current(fn_ctx, ¶ms_partial, data).await? @@ -146,14 +146,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); I::state_current(fn_ctx, ¶ms, data).await? @@ -176,14 +176,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Goal, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); let state_goal = I::try_state_goal(fn_ctx, ¶ms_partial, data).await?; @@ -223,14 +223,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( value_resolution_mode, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); let state_goal = I::state_goal(fn_ctx, ¶ms, data).await?; @@ -297,14 +297,14 @@ where // // Running `diff` for multiple profiles will likely be between two profiles' // current states. - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Goal, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); I::state_diff(¶ms_partial, data, state_a, state_b) @@ -339,14 +339,14 @@ where // parameters to be used. Note that during an apply, the goal state is // resolved as execution happens -- values that rely on predecessors' applied // state will be fed into successors' goal state. - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( value_resolution_mode, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); if let Ok(params) = params_partial.try_into() { @@ -379,14 +379,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); let state_ensured_dry = @@ -415,14 +415,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError)? + .map_err(crate::Error::ParamsResolveError::)? }; let data = as Data>::borrow(self.id(), resources); let state_ensured = I::apply(fn_ctx, ¶ms, data, state_current, state_goal, state_diff) @@ -832,7 +832,7 @@ where async fn clean_prepare( &self, - states_current: &StatesCurrent, + states_current: &StatesCurrent, params_specs: &ParamsSpecs, resources: &Resources, ) -> Result { diff --git a/crate/rt_model/src/states_serializer.rs b/crate/rt_model/src/states_serializer.rs index b4e03a6cf..bcc765819 100644 --- a/crate/rt_model/src/states_serializer.rs +++ b/crate/rt_model/src/states_serializer.rs @@ -12,16 +12,16 @@ use peace_resources::{ use crate::{Error, ItemGraph, Storage}; -/// Reads and writes [`StatesCurrentStored`] and [`StatesGoalStored`] to and -/// from storage. +/// Reads and writes [`StatesCurrentStored`] and +/// [`StatesGoalStored`] to and from storage. pub struct StatesSerializer(PhantomData); impl StatesSerializer where E: std::error::Error + From + Send + 'static, { - /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it exists on - /// disk. + /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it + /// exists on disk. /// /// # Parameters: /// @@ -30,10 +30,10 @@ where /// * `states_file_path`: Path to save the serialized states to. /// /// [`Item`]: peace_cfg::Item - pub async fn serialize( + pub async fn serialize( storage: &Storage, item_graph: &ItemGraph, - states: &States, + states: &States, states_file_path: &Path, ) -> Result<(), E> where @@ -53,8 +53,8 @@ where Ok(()) } - /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it exists on - /// disk. + /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it + /// exists on disk. /// /// # Parameters: /// @@ -69,7 +69,7 @@ where storage: &Storage, states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, - ) -> Result { + ) -> Result, E> { let states = Self::deserialize_internal::( #[cfg(not(target_arch = "wasm32"))] "StatesSerializer::deserialize_stored".to_string(), @@ -83,7 +83,8 @@ where states.ok_or_else(|| E::from(Error::StatesCurrentDiscoverRequired)) } - /// Returns the [`StatesGoalStored`] of all [`Item`]s if it exists on disk. + /// Returns the [`StatesGoalStored`] of all [`Item`]s if it exists + /// on disk. /// /// # Parameters: /// @@ -98,7 +99,7 @@ where storage: &Storage, states_type_reg: &TypeReg, states_goal_file: &StatesGoalFile, - ) -> Result { + ) -> Result, E> { let states = Self::deserialize_internal::( #[cfg(not(target_arch = "wasm32"))] "StatesSerializer::deserialize_goal".to_string(), @@ -112,8 +113,8 @@ where states.ok_or_else(|| E::from(Error::StatesGoalDiscoverRequired)) } - /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it exists on - /// disk. + /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it + /// exists on disk. /// /// # Parameters: /// @@ -128,7 +129,7 @@ where storage: &Storage, states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, - ) -> Result, E> { + ) -> Result>, E> { Self::deserialize_internal( #[cfg(not(target_arch = "wasm32"))] "StatesSerializer::deserialize_stored_opt".to_string(), @@ -158,13 +159,13 @@ where /// [`ts::Current`]: peace_resources::states::ts::Current /// [`ts::CurrentStored`]: peace_resources::states::ts::CurrentStored #[cfg(not(target_arch = "wasm32"))] - async fn deserialize_internal( + async fn deserialize_internal( thread_name: String, flow_id: &FlowId, storage: &Storage, states_type_reg: &TypeReg, states_file_path: &Path, - ) -> Result>, E> + ) -> Result>, E> where TS: Send + Sync, { @@ -226,12 +227,12 @@ where /// [`ts::Current`]: peace_resources::states::ts::Current /// [`ts::CurrentStored`]: peace_resources::states::ts::CurrentStored #[cfg(target_arch = "wasm32")] - async fn deserialize_internal( + async fn deserialize_internal( flow_id: &FlowId, storage: &Storage, states_type_reg: &TypeReg, states_file_path: &Path, - ) -> Result>, E> + ) -> Result>, E> where TS: Send + Sync, { diff --git a/workspace_tests/src/cfg/stored.rs b/workspace_tests/src/cfg/stored.rs index 44d063d08..c968e50fb 100644 --- a/workspace_tests/src/cfg/stored.rs +++ b/workspace_tests/src/cfg/stored.rs @@ -16,7 +16,7 @@ fn retrieves_state_for_item() { let mut states_mut = StatesMut::new(); states_mut.insert(ITEM_SPEC_ID_TEST.clone(), 123u8); - StatesCurrentStored::from(states_mut) + StatesCurrentStored::::from(states_mut) }; resources.insert(states_current_stored); @@ -32,7 +32,7 @@ fn does_not_retrieve_state_for_item_other() { let mut states_mut = StatesMut::new(); states_mut.insert(ITEM_SPEC_ID_OTHER.clone(), 123u8); - StatesCurrentStored::from(states_mut) + StatesCurrentStored::::from(states_mut) }; resources.insert(states_current_stored); @@ -44,7 +44,7 @@ fn does_not_retrieve_state_for_item_other() { #[test] fn data_access_borrows_returns_states_current_stored_type_id() { let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::()); + type_ids.push(TypeId::of::>()); assert_eq!(type_ids, as DataAccess>::borrows()); } @@ -59,12 +59,12 @@ fn data_access_borrow_muts_is_empty() { #[test] fn data_access_dyn_borrows_returns_states_current_stored_type_id() { let mut resources = Resources::new(); - let states_current_stored = StatesCurrentStored::from(StatesMut::new()); + let states_current_stored = StatesCurrentStored::::from(StatesMut::new()); resources.insert(states_current_stored); let stored = Stored::<'_, u8>::borrow(ITEM_SPEC_ID_TEST, &resources); let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::()); + type_ids.push(TypeId::of::>()); assert_eq!( type_ids, @@ -75,7 +75,7 @@ fn data_access_dyn_borrows_returns_states_current_stored_type_id() { #[test] fn data_access_dyn_borrow_muts_is_empty() { let mut resources = Resources::new(); - let states_current_stored = StatesCurrentStored::from(StatesMut::new()); + let states_current_stored = StatesCurrentStored::::from(StatesMut::new()); resources.insert(states_current_stored); let stored = Stored::<'_, u8>::borrow(ITEM_SPEC_ID_TEST, &resources); @@ -94,7 +94,7 @@ fn debug() { let mut states_mut = StatesMut::new(); states_mut.insert(ITEM_SPEC_ID_TEST.clone(), 123u8); - StatesCurrentStored::from(states_mut) + StatesCurrentStored::::from(states_mut) }; resources.insert(states_current_stored); diff --git a/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs b/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs index e9b26e461..31d2eb448 100644 --- a/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs +++ b/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs @@ -418,7 +418,7 @@ async fn build_with_item_params_returns_ok_when_params_provided() let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -518,7 +518,7 @@ async fn build_with_item_params_returns_ok_when_params_not_provided_but_are_stor let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -571,7 +571,7 @@ async fn build_with_item_params_returns_ok_and_uses_params_provided_when_params_ let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -779,7 +779,7 @@ async fn build_with_item_params_returns_ok_when_spec_provided_for_previous_mappi let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -1066,7 +1066,7 @@ async fn build_with_item_params_returns_ok_when_new_item_added_with_params_provi let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), diff --git a/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs b/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs index 123ad3114..5eeadfee7 100644 --- a/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs +++ b/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs @@ -69,9 +69,9 @@ async fn builds_error_for_missing_input_tuple_first_parameter() -> Result<(), Pe })) => { assert_eq!(2, cmd_block_descs.len()); assert_eq!(1, cmd_block_index); - assert_eq!("States", input_name_short); + assert_eq!("States", input_name_short); assert_eq!( - "peace_resources::states::States", + "peace_resources::states::States", input_name_full ); #[cfg(feature = "error_reporting")] @@ -82,17 +82,17 @@ async fn builds_error_for_missing_input_tuple_first_parameter() -> Result<(), Pe CmdBlocks: - StatesDiscoverCmdBlock: Input: () - Outcome: States + Outcome: States - DiffCmdBlock: - Input: (States, States) - Outcome: (StateDiffs, States, States) + Input: (States, States) + Outcome: (StateDiffs, States, States) "#, cmd_execution_src ); match input_span { Some(input_span) => { assert_eq!(154, input_span.offset()); - assert_eq!("States".len(), input_span.len()); + assert_eq!("States".len(), input_span.len()); } None => panic!( "Expected `input_span` to be `Some(SourceSpan::from((154, 15)))`, but was `None`." @@ -158,9 +158,9 @@ async fn builds_error_for_missing_input_tuple_second_parameter() -> Result<(), P })) => { assert_eq!(2, cmd_block_descs.len()); assert_eq!(1, cmd_block_index); - assert_eq!("States", input_name_short); + assert_eq!("States", input_name_short); assert_eq!( - "peace_resources::states::States", + "peace_resources::states::States", input_name_full ); #[cfg(feature = "error_reporting")] @@ -171,17 +171,17 @@ async fn builds_error_for_missing_input_tuple_second_parameter() -> Result<(), P CmdBlocks: - StatesDiscoverCmdBlock: Input: () - Outcome: States + Outcome: States - DiffCmdBlock: - Input: (States, States) - Outcome: (StateDiffs, States, States) + Input: (States, States) + Outcome: (StateDiffs, States, States) "#, cmd_execution_src ); match input_span { Some(input_span) => { assert_eq!(174, input_span.offset()); - assert_eq!("States".len(), input_span.len()); + assert_eq!("States".len(), input_span.len()); } None => panic!( "Expected `input_span` to be `Some(SourceSpan::from((174, 12)))`, but was `None`." diff --git a/workspace_tests/src/items/tar_x_item.rs b/workspace_tests/src/items/tar_x_item.rs index fa83a1582..9ce28f595 100644 --- a/workspace_tests/src/items/tar_x_item.rs +++ b/workspace_tests/src/items/tar_x_item.rs @@ -572,7 +572,7 @@ async fn ensure_check_returns_exec_not_required_when_tar_and_dest_in_sync() let tar_x_params_spec = params_specs .get::>, _>(TarXTest::ID) .unwrap(); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, TarXTest::ID.clone(), tynm::type_name::>(), diff --git a/workspace_tests/src/mock_item.rs b/workspace_tests/src/mock_item.rs index 3d2967d97..8851b5e75 100644 --- a/workspace_tests/src/mock_item.rs +++ b/workspace_tests/src/mock_item.rs @@ -350,8 +350,10 @@ where resources.insert(self.mock_fns.clone()); let mock_dest = { - let states_current_stored = - as Data>::borrow(Self::ID_DEFAULT, resources); + let states_current_stored = > as Data>::borrow( + Self::ID_DEFAULT, + resources, + ); let mock_state_current_stored: Option<&'_ MockState> = states_current_stored .as_ref() .and_then(|states_current_stored| states_current_stored.get(self.id())); diff --git a/workspace_tests/src/params/derive.rs b/workspace_tests/src/params/derive.rs index 830f1efc4..8dd941ecc 100644 --- a/workspace_tests/src/params/derive.rs +++ b/workspace_tests/src/params/derive.rs @@ -134,7 +134,7 @@ mod struct_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("StructParams"), @@ -345,7 +345,7 @@ mod struct_with_type_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("StructWithTypeParams<()>"), @@ -547,7 +547,7 @@ mod tuple_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("TupleParams"), @@ -727,7 +727,7 @@ mod tuple_with_type_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("TupleWithTypeParams<()>"), @@ -1011,7 +1011,7 @@ mod enum_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_named_from_field_wise_builder"), String::from("EnumParams<()>"), @@ -1046,7 +1046,7 @@ mod enum_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_tuple_from_field_wise_builder"), String::from("EnumParams<()>"), @@ -1080,7 +1080,7 @@ mod enum_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_tuple_marker_from_field_wise_builder"), String::from("EnumParams<()>"), @@ -1585,7 +1585,7 @@ mod struct_recursive_value { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("StructRecursiveValue<()>"), diff --git a/workspace_tests/src/params/mapping_fn_impl.rs b/workspace_tests/src/params/mapping_fn_impl.rs index ad7df3c0e..504ebcce8 100644 --- a/workspace_tests/src/params/mapping_fn_impl.rs +++ b/workspace_tests/src/params/mapping_fn_impl.rs @@ -43,7 +43,7 @@ macro_rules! mapping_tests { data::marker::$value_resolution_mode, cfg::{item_id}, params::{ - MappingFn, MappingFnImpl, ParamsResolveError, + MappingFn, MappingFnImpl, ParamsResolveError, ValueResolutionCtx, ValueResolutionMode, }, resources::{resources::ts::SetUp, Resources}, @@ -51,7 +51,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_ok_when_referenced_values_are_present_directly() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -64,7 +64,7 @@ macro_rules! mapping_tests { resources.insert(2u64); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -82,7 +82,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_ok_when_referenced_values_are_present_through_data_marker() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -95,7 +95,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -113,7 +113,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_err_when_referenced_value_is_none() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -126,7 +126,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(None::)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -143,7 +143,7 @@ macro_rules! mapping_tests { assert!( matches!( &sum_result, - Err(ParamsResolveError::FromMap { + Err(ParamsResolveError::::FromMap { value_resolution_ctx, from_type_name }) @@ -160,7 +160,7 @@ macro_rules! mapping_tests { && from_type_name == "u64" // u64 is missing from `resources` ), "expected `sum_result` to be \ - `Err(ParamsResolveError::FromMap {{ .. }}`,\n\ + `Err(ParamsResolveError::::FromMap {{ .. }}`,\n\ but was {sum_result:?}" ); } @@ -171,7 +171,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_err_when_referenced_value_is_absent() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -184,7 +184,7 @@ macro_rules! mapping_tests { // resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -202,7 +202,7 @@ macro_rules! mapping_tests { assert!( matches!( &sum_result, - Err(ParamsResolveError::FromMap { + Err(ParamsResolveError::::FromMap { value_resolution_ctx, from_type_name }) @@ -219,7 +219,7 @@ macro_rules! mapping_tests { && from_type_name == "u64" // u64 is missing from `resources` ), "expected `sum_result` to be \ - `Err(ParamsResolveError::FromMap {{ .. }}`,\n\ + `Err(ParamsResolveError::::FromMap {{ .. }}`,\n\ but was {sum_result:?}" ); } @@ -230,7 +230,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_try_map_returns_ok_some_when_referenced_values_are_present() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -243,7 +243,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -261,7 +261,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_try_map_returns_ok_none_when_referenced_value_is_none() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -274,7 +274,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(None::)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -292,7 +292,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_try_map_returns_ok_none_when_referenced_value_is_absent() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -305,7 +305,7 @@ macro_rules! mapping_tests { // resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), diff --git a/workspace_tests/src/params/params_spec.rs b/workspace_tests/src/params/params_spec.rs index 814632c5d..06b758d16 100644 --- a/workspace_tests/src/params/params_spec.rs +++ b/workspace_tests/src/params/params_spec.rs @@ -240,7 +240,7 @@ marker: null #[test] fn deserialize_field_wise_value() -> Result<(), Box> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::ApplyDry, item_id!("deserialize_field_wise"), tynm::type_name::(), @@ -402,13 +402,13 @@ field_wise_spec: !MappingFn } #[test] -fn resolve_stored_param() -> Result<(), ParamsResolveError> { +fn resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_stored_param"), tynm::type_name::(), @@ -422,13 +422,13 @@ fn resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory() -> Result<(), ParamsResolveError> { +fn resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory"), tynm::type_name::(), @@ -442,9 +442,9 @@ fn resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_not_found"), tynm::type_name::(), @@ -460,14 +460,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemory { value_resolution_ctx }) + Err(ParamsResolveError::InMemory { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_not_found") && value_resolution_ctx.params_type_name() == "MockSrc" && value_resolution_ctx.resolution_chain().is_empty() ), - "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ + "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ but was `{mock_src_result:?}`" ); } @@ -476,13 +476,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr } #[test] -fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -499,7 +500,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_mutably_borrowed") @@ -507,7 +508,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -517,9 +518,9 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes } #[test] -fn resolve_value() -> Result<(), ParamsResolveError> { +fn resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_value"), tynm::type_name::(), @@ -533,13 +534,13 @@ fn resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn"), tynm::type_name::(), @@ -553,14 +554,15 @@ fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -578,7 +580,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -587,7 +589,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -597,13 +599,13 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn resolve_field_wise() -> Result<(), ParamsResolveError> { +fn resolve_field_wise() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_field_wise"), tynm::type_name::(), @@ -617,13 +619,14 @@ fn resolve_field_wise() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_field_wise_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -640,7 +643,7 @@ fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_field_wise_returns_err_when_mutably_borrowed") @@ -650,7 +653,7 @@ fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe ] ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[(0, u8)]`,\n\ but was `{mock_src_result:?}`" ); @@ -660,13 +663,13 @@ fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { +fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_stored_param"), tynm::type_name::(), @@ -680,13 +683,13 @@ fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory"), tynm::type_name::(), @@ -700,9 +703,9 @@ fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_none_when_not_found"), tynm::type_name::(), @@ -716,13 +719,14 @@ fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResol } #[test] -fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -739,7 +743,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed") @@ -747,7 +751,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -757,9 +761,9 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param } #[test] -fn try_resolve_value() -> Result<(), ParamsResolveError> { +fn try_resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_value"), tynm::type_name::(), @@ -773,13 +777,13 @@ fn try_resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn"), tynm::type_name::(), @@ -793,14 +797,15 @@ fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -818,7 +823,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -827,7 +832,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -837,13 +842,13 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para } #[test] -fn try_resolve_field_wise() -> Result<(), ParamsResolveError> { +fn try_resolve_field_wise() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_field_wise"), tynm::type_name::(), @@ -857,13 +862,14 @@ fn try_resolve_field_wise() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_field_wise_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_field_wise_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -880,7 +886,7 @@ fn try_resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), Para assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_field_wise_returns_err_when_mutably_borrowed") @@ -890,7 +896,7 @@ fn try_resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), Para ] ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[(0, u8)]`,\n\ but was `{mock_src_result:?}`" ); diff --git a/workspace_tests/src/params/params_spec_fieldless.rs b/workspace_tests/src/params/params_spec_fieldless.rs index 7d0cc66f5..905b711e8 100644 --- a/workspace_tests/src/params/params_spec_fieldless.rs +++ b/workspace_tests/src/params/params_spec_fieldless.rs @@ -208,13 +208,13 @@ marker: null } #[test] -fn resolve_stored_param() -> Result<(), ParamsResolveError> { +fn resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_stored_param"), tynm::type_name::(), @@ -228,13 +228,13 @@ fn resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory() -> Result<(), ParamsResolveError> { +fn resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory"), tynm::type_name::(), @@ -248,9 +248,9 @@ fn resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_not_found"), tynm::type_name::(), @@ -266,14 +266,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemory { value_resolution_ctx }) + Err(ParamsResolveError::InMemory { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_not_found") && value_resolution_ctx.params_type_name() == "MockSrc" && value_resolution_ctx.resolution_chain().is_empty() ), - "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ + "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ but was `{mock_src_result:?}`" ); } @@ -282,13 +282,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr } #[test] -fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -305,7 +306,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_mutably_borrowed") @@ -313,7 +314,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -323,9 +324,9 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes } #[test] -fn resolve_value() -> Result<(), ParamsResolveError> { +fn resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_value"), tynm::type_name::(), @@ -339,13 +340,13 @@ fn resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn"), tynm::type_name::(), @@ -359,14 +360,15 @@ fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -385,7 +387,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -394,7 +396,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -404,13 +406,13 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { +fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_stored_param"), tynm::type_name::(), @@ -424,13 +426,13 @@ fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory"), tynm::type_name::(), @@ -444,9 +446,9 @@ fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_none_when_not_found"), tynm::type_name::(), @@ -460,13 +462,14 @@ fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResol } #[test] -fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -483,7 +486,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed") @@ -491,7 +494,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -501,9 +504,9 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param } #[test] -fn try_resolve_value() -> Result<(), ParamsResolveError> { +fn try_resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_value"), tynm::type_name::(), @@ -517,13 +520,13 @@ fn try_resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn"), tynm::type_name::(), @@ -537,14 +540,15 @@ fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -563,7 +567,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -572,7 +576,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); diff --git a/workspace_tests/src/params/value_resolution_ctx.rs b/workspace_tests/src/params/value_resolution_ctx.rs index 73719c271..864f42897 100644 --- a/workspace_tests/src/params/value_resolution_ctx.rs +++ b/workspace_tests/src/params/value_resolution_ctx.rs @@ -1,20 +1,20 @@ use peace::{ cfg::item_id, - params::{FieldNameAndType, ValueResolutionCtx, ValueResolutionMode}, + params::{FieldNameAndType, ValueResolutionCtx, ValueResolutionMode}, }; use crate::mock_item::MockSrc; #[test] fn debug() { - let value_resolution_ctx = ValueResolutionCtx::new( + let value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("item_id"), tynm::type_name::(), ); assert_eq!( - "ValueResolutionCtx { \ + "ValueResolutionCtx { \ value_resolution_mode: Current, \ item_id: ItemId(\"item_id\"), \ params_type_name: \"MockSrc\", \ @@ -26,13 +26,13 @@ fn debug() { #[test] fn partial_eq() { - let value_resolution_ctx_0 = ValueResolutionCtx::new( + let value_resolution_ctx_0 = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("item_id_0"), tynm::type_name::(), ); - let value_resolution_ctx_1 = ValueResolutionCtx::new( + let value_resolution_ctx_1 = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("item_id_1"), tynm::type_name::(), @@ -44,7 +44,7 @@ fn partial_eq() { #[test] fn display_no_resolution_chain() { - let value_resolution_ctx = ValueResolutionCtx::new( + let value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("item_id"), tynm::type_name::(), @@ -55,7 +55,7 @@ fn display_no_resolution_chain() { #[test] fn display_with_resolution_chain() { - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("item_id"), tynm::type_name::(), diff --git a/workspace_tests/src/params/value_spec.rs b/workspace_tests/src/params/value_spec.rs index e73cfa04b..962dc0a9a 100644 --- a/workspace_tests/src/params/value_spec.rs +++ b/workspace_tests/src/params/value_spec.rs @@ -197,13 +197,13 @@ marker: null } #[test] -fn resolve_stored_param() -> Result<(), ParamsResolveError> { +fn resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_stored_param"), tynm::type_name::(), @@ -217,13 +217,13 @@ fn resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory() -> Result<(), ParamsResolveError> { +fn resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory"), tynm::type_name::(), @@ -237,9 +237,9 @@ fn resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_not_found"), tynm::type_name::(), @@ -255,14 +255,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemory { value_resolution_ctx }) + Err(ParamsResolveError::InMemory { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_not_found") && value_resolution_ctx.params_type_name() == "MockSrc" && value_resolution_ctx.resolution_chain().is_empty() ), - "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ + "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ but was `{mock_src_result:?}`" ); } @@ -271,13 +271,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr } #[test] -fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -294,7 +295,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_mutably_borrowed") @@ -302,7 +303,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -312,9 +313,9 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes } #[test] -fn resolve_value() -> Result<(), ParamsResolveError> { +fn resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_value"), tynm::type_name::(), @@ -328,13 +329,13 @@ fn resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn"), tynm::type_name::(), @@ -348,14 +349,15 @@ fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> +{ let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -373,7 +375,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -382,7 +384,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -392,13 +394,13 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { +fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_stored_param"), tynm::type_name::(), @@ -412,13 +414,13 @@ fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory"), tynm::type_name::(), @@ -432,9 +434,9 @@ fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_none_when_not_found"), tynm::type_name::(), @@ -448,13 +450,14 @@ fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResol } #[test] -fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -471,7 +474,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed") @@ -479,7 +482,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -489,9 +492,9 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), Param } #[test] -fn try_resolve_value() -> Result<(), ParamsResolveError> { +fn try_resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_value"), tynm::type_name::(), @@ -505,13 +508,13 @@ fn try_resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn"), tynm::type_name::(), @@ -525,14 +528,15 @@ fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() +-> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::new( + let mut value_resolution_ctx = ValueResolutionCtx::::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -550,7 +554,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -559,7 +563,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), Para && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); diff --git a/workspace_tests/src/resources/resources.rs b/workspace_tests/src/resources/resources.rs index 89316ae50..805a7a3d5 100644 --- a/workspace_tests/src/resources/resources.rs +++ b/workspace_tests/src/resources/resources.rs @@ -36,6 +36,6 @@ fn resources_set_up_from_resources_empty() { let resources_set_up = Resources::::from(resources_empty); // no default resources - assert!(!resources_set_up.contains::()); - assert!(!resources_set_up.contains::()); + assert!(!resources_set_up.contains::>()); + assert!(!resources_set_up.contains::>()); } diff --git a/workspace_tests/src/resources/state_diffs.rs b/workspace_tests/src/resources/state_diffs.rs index 0d37435ed..c0c4caf92 100644 --- a/workspace_tests/src/resources/state_diffs.rs +++ b/workspace_tests/src/resources/state_diffs.rs @@ -41,7 +41,7 @@ fn debug() { let state_diffs = test_state_diffs(); assert_eq!( - r#"StateDiffs({ItemId("key"): TypedValue { type: "i32", value: 123 }})"#, + r#"StateDiffs({ItemId("key"): TypedValue { type: "i32", value: 123 }})"#, format!("{state_diffs:?}") ); } diff --git a/workspace_tests/src/resources/states/states_cleaned_dry.rs b/workspace_tests/src/resources/states/states_cleaned_dry.rs index bc80160e7..db19ccb7a 100644 --- a/workspace_tests/src/resources/states/states_cleaned_dry.rs +++ b/workspace_tests/src/resources/states/states_cleaned_dry.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCleanedDry, StatesCurrent}; #[test] fn from_states_current() { - let _states_cleaned_dry = StatesCleanedDry::from(StatesCurrent::new()); + let _states_cleaned_dry = StatesCleanedDry::::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_current.rs b/workspace_tests/src/resources/states/states_current.rs index 61af6ca58..062518318 100644 --- a/workspace_tests/src/resources/states/states_current.rs +++ b/workspace_tests/src/resources/states/states_current.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesCurrentStored}; #[test] fn from_states_current_stored() { - let _states_current = StatesCurrent::from(StatesCurrentStored::new()); + let _states_current = StatesCurrent::from(StatesCurrentStored::::new()); } diff --git a/workspace_tests/src/resources/states/states_current_stored.rs b/workspace_tests/src/resources/states/states_current_stored.rs index cf94be9a0..899956d54 100644 --- a/workspace_tests/src/resources/states/states_current_stored.rs +++ b/workspace_tests/src/resources/states/states_current_stored.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesCurrentStored}; #[test] fn from_states_current() { - let _states_current_stored = StatesCurrentStored::from(StatesCurrent::new()); + let _states_current_stored = StatesCurrentStored::::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_ensured.rs b/workspace_tests/src/resources/states/states_ensured.rs index ab99aaeda..819f57bca 100644 --- a/workspace_tests/src/resources/states/states_ensured.rs +++ b/workspace_tests/src/resources/states/states_ensured.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesEnsured}; #[test] fn from_states_current() { - let _states_ensured = StatesEnsured::from(StatesCurrent::new()); + let _states_ensured = StatesEnsured::::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_ensured_dry.rs b/workspace_tests/src/resources/states/states_ensured_dry.rs index 682b9739e..dcb959fc6 100644 --- a/workspace_tests/src/resources/states/states_ensured_dry.rs +++ b/workspace_tests/src/resources/states/states_ensured_dry.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesEnsuredDry}; #[test] fn from_states_current() { - let _states_ensured_dry = StatesEnsuredDry::from(StatesCurrent::new()); + let _states_ensured_dry = StatesEnsuredDry::::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_goal.rs b/workspace_tests/src/resources/states/states_goal.rs index b6234aae1..cbf08b2e4 100644 --- a/workspace_tests/src/resources/states/states_goal.rs +++ b/workspace_tests/src/resources/states/states_goal.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesGoal, StatesGoalStored}; #[test] fn from_states_goal_stored() { - let _states_goal = StatesGoal::from(StatesGoalStored::new()); + let _states_goal = StatesGoal::from(StatesGoalStored::::new()); } diff --git a/workspace_tests/src/resources/states/states_goal_stored.rs b/workspace_tests/src/resources/states/states_goal_stored.rs index 27554623f..8f4eb353d 100644 --- a/workspace_tests/src/resources/states/states_goal_stored.rs +++ b/workspace_tests/src/resources/states/states_goal_stored.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesGoal, StatesGoalStored}; #[test] fn from_states_goal() { - let _states_goal_stored = StatesGoalStored::from(StatesGoal::new()); + let _states_goal_stored = StatesGoalStored::::from(StatesGoal::new()); } diff --git a/workspace_tests/src/resources/states/states_previous.rs b/workspace_tests/src/resources/states/states_previous.rs index 45e6f7902..8310516e3 100644 --- a/workspace_tests/src/resources/states/states_previous.rs +++ b/workspace_tests/src/resources/states/states_previous.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesPrevious}; #[test] fn from_states_current() { - let _states_previous = StatesPrevious::from(StatesCurrent::new()); + let _states_previous = StatesPrevious::::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs index a96cefc96..3f591aa52 100644 --- a/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs @@ -18,10 +18,22 @@ fn input_type_names_includes_states_current_and_states_target() { }; } - assert_input_type_names!(Ensured, &["States", "States"]); - assert_input_type_names!(EnsuredDry, &["States", "States"]); - assert_input_type_names!(Cleaned, &["States", "States"]); - assert_input_type_names!(CleanedDry, &["States", "States"]); + assert_input_type_names!( + Ensured, + &["States", "States"] + ); + assert_input_type_names!( + EnsuredDry, + &["States", "States"] + ); + assert_input_type_names!( + Cleaned, + &["States", "States"] + ); + assert_input_type_names!( + CleanedDry, + &["States", "States"] + ); } #[test] @@ -38,18 +50,34 @@ fn outcome_type_names_includes_states_previous_states_target() { assert_outcome_type_names!( Ensured, - &["States", "States", "States"] + &[ + "States", + "States", + "States" + ] ); assert_outcome_type_names!( EnsuredDry, - &["States", "States", "States"] + &[ + "States", + "States", + "States" + ] ); assert_outcome_type_names!( Cleaned, - &["States", "States", "States"] + &[ + "States", + "States", + "States" + ] ); assert_outcome_type_names!( CleanedDry, - &["States", "States", "States"] + &[ + "States", + "States", + "States" + ] ); } diff --git a/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs index 454ff82dd..1e2c2d8c2 100644 --- a/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs @@ -15,15 +15,21 @@ fn input_type_names_includes_states_compared() { } assert_input_type_names!(none, &[]); - assert_input_type_names!(current, &["States", "States"]); - assert_input_type_names!(goal, &["States", "States"]); + assert_input_type_names!( + current, + &["States", "States"] + ); + assert_input_type_names!( + goal, + &["States", "States"] + ); assert_input_type_names!( current_and_goal, &[ - "States", - "States", - "States", - "States" + "States", + "States", + "States", + "States" ] ); } @@ -41,15 +47,21 @@ fn outcome_type_names_includes_states_compared() { } assert_outcome_type_names!(none, &[]); - assert_outcome_type_names!(current, &["States", "States"]); - assert_outcome_type_names!(goal, &["States", "States"]); + assert_outcome_type_names!( + current, + &["States", "States"] + ); + assert_outcome_type_names!( + goal, + &["States", "States"] + ); assert_outcome_type_names!( current_and_goal, &[ - "States", - "States", - "States", - "States" + "States", + "States", + "States", + "States" ] ); } diff --git a/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs index 0be3226cb..e5f328640 100644 --- a/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs @@ -18,11 +18,18 @@ fn input_type_names_includes_states_ts0_and_states_ts1() { }; } - assert_input_type_names!(Current, Goal, &["States", "States"]); + assert_input_type_names!( + Current, + Goal, + &["States", "States"] + ); assert_input_type_names!( CurrentStored, GoalStored, - &["States", "States"] + &[ + "States", + "States" + ] ); } @@ -41,11 +48,19 @@ fn outcome_type_names_includes_state_diffs_states_ts0_and_states_ts1() { assert_outcome_type_names!( Current, Goal, - &["StateDiffs", "States", "States"] + &[ + "StateDiffs", + "States", + "States" + ] ); assert_outcome_type_names!( CurrentStored, GoalStored, - &["StateDiffs", "States", "States"] + &[ + "StateDiffs", + "States", + "States" + ] ); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs index 127a0de7a..1043d95aa 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs @@ -17,5 +17,5 @@ fn outcome_type_names_includes_states_clean() { let outcome_type_names: Vec = cmd_block.outcome_type_names(); - assert_eq!(&["States"], outcome_type_names.as_slice()); + assert_eq!(&["States"], outcome_type_names.as_slice()); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs index bfc44b178..6f3c882a4 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs @@ -17,5 +17,8 @@ fn outcome_type_names_includes_states_current_stored() { let outcome_type_names: Vec = cmd_block.outcome_type_names(); - assert_eq!(&["States"], outcome_type_names.as_slice()); + assert_eq!( + &["States"], + outcome_type_names.as_slice() + ); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs index 2300c3825..c3b356ebe 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs @@ -31,7 +31,10 @@ fn outcome_type_names_includes_states_compared() { }; } - assert_outcome_type_names!(current, &["States"]); - assert_outcome_type_names!(goal, &["States"]); - assert_outcome_type_names!(current_and_goal, &["States", "States"]); + assert_outcome_type_names!(current, &["States"]); + assert_outcome_type_names!(goal, &["States"]); + assert_outcome_type_names!( + current_and_goal, + &["States", "States"] + ); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs index 4a2ade018..06e906a6d 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs @@ -17,5 +17,8 @@ fn outcome_type_names_includes_states_goal_stored() { let outcome_type_names: Vec = cmd_block.outcome_type_names(); - assert_eq!(&["States"], outcome_type_names.as_slice()); + assert_eq!( + &["States"], + outcome_type_names.as_slice() + ); } diff --git a/workspace_tests/src/rt/cmds/diff_cmd.rs b/workspace_tests/src/rt/cmds/diff_cmd.rs index 12b55487c..d4574a4e7 100644 --- a/workspace_tests/src/rt/cmds/diff_cmd.rs +++ b/workspace_tests/src/rt/cmds/diff_cmd.rs @@ -140,7 +140,7 @@ async fn diff_discover_current_on_demand() -> Result<(), Box(); + let states_current = resources.borrow::>(); let vec_diff = state_diffs.get::(VecCopyItem::ID_DEFAULT); let vec_copy_current_state = states_current.get::(VecCopyItem::ID_DEFAULT); @@ -215,7 +215,7 @@ async fn diff_discover_goal_on_demand() -> Result<(), Box // Note: discovered `StatesGoal` is not automatically serialized to storage. let resources = &cmd_ctx.view().resources; - let states_goal = resources.borrow::(); + let states_goal = resources.borrow::>(); let vec_diff = state_diffs.get::(VecCopyItem::ID_DEFAULT); let vec_copy_current_state = states_current.get::(VecCopyItem::ID_DEFAULT); @@ -284,8 +284,8 @@ async fn diff_discover_current_and_goal_on_demand() -> Result<(), Box(); - let states_goal = resources.borrow::(); + let states_current = resources.borrow::>(); + let states_goal = resources.borrow::>(); let vec_diff = state_diffs.get::(VecCopyItem::ID_DEFAULT); let vec_copy_current_state = states_current.get::(VecCopyItem::ID_DEFAULT); diff --git a/workspace_tests/src/rt/cmds/ensure_cmd.rs b/workspace_tests/src/rt/cmds/ensure_cmd.rs index 45f81fc5b..e929ddf88 100644 --- a/workspace_tests/src/rt/cmds/ensure_cmd.rs +++ b/workspace_tests/src/rt/cmds/ensure_cmd.rs @@ -53,8 +53,8 @@ async fn resources_ensured_dry_does_not_alter_state() -> Result<(), Box`, + // but it would be useful to return simulated ensured states. let CmdOutcome::Complete { value: states_ensured_dry, cmd_blocks_processed: _, @@ -67,8 +67,8 @@ async fn resources_ensured_dry_does_not_alter_state() -> Result<(), Box(); - // let states_goal = resources.borrow::(); + // let states = resources.borrow::>(); + // let states_goal = resources.borrow::>(); // assert_eq!( // Some(VecCopyState::new()).as_ref(), // states.get::(&VecCopyItem::ID_DEFAULT) @@ -154,8 +154,8 @@ async fn resources_ensured_contains_state_ensured_for_each_item_when_state_not_y // was discovered. // // ```rust,ignore - // let ensured_states_before = resources_ensured.borrow::(); - // let ensured_states_goal = resources_ensured.borrow::(); + // let ensured_states_before = resources_ensured.borrow::>(); + // let ensured_states_goal = resources_ensured.borrow::>(); // assert_eq!( // Some(VecCopyState::new()).as_ref(), // ensured_states_before.get::(&VecCopyItem::ID_DEFAULT) diff --git a/workspace_tests/src/rt/cmds/states_discover_cmd.rs b/workspace_tests/src/rt/cmds/states_discover_cmd.rs index 7faf068ce..3be8bb4ee 100644 --- a/workspace_tests/src/rt/cmds/states_discover_cmd.rs +++ b/workspace_tests/src/rt/cmds/states_discover_cmd.rs @@ -194,7 +194,7 @@ async fn current_inserts_states_current_stored_from_states_current_file() // Writes to states_current_file.yaml StatesDiscoverCmd::current(&mut cmd_ctx).await?; - // Execute again to ensure StatesCurrentStored is included + // Execute again to ensure StatesCurrentStored is included // // Note: The actual logic is part of `CmdCtxBuilder::build`, implemented by // `impl_build.rs`. @@ -208,7 +208,7 @@ async fn current_inserts_states_current_stored_from_states_current_file() .await?; StatesDiscoverCmd::current(&mut cmd_ctx).await?; let resources = cmd_ctx.resources(); - let states_current_stored_from_cmd_ctx = resources.borrow::(); + let states_current_stored_from_cmd_ctx = resources.borrow::>(); let mut output = NoOpOutput; let mut cmd_ctx = CmdCtx::builder_single_profile_single_flow(&mut output, &workspace) diff --git a/workspace_tests/src/rt_model/item_wrapper.rs b/workspace_tests/src/rt_model/item_wrapper.rs index 984ed3b03..c3468528e 100644 --- a/workspace_tests/src/rt_model/item_wrapper.rs +++ b/workspace_tests/src/rt_model/item_wrapper.rs @@ -660,7 +660,7 @@ async fn resources_set_up( async fn resources_set_up_with_pre_stored_state( item_wrapper: &VecCopyItemWrapper, -) -> Result<(ParamsSpecs, Resources, StatesCurrent), VecCopyError> { +) -> Result<(ParamsSpecs, Resources, StatesCurrent), VecCopyError> { let (params_specs, mut resources) = resources_set_up(item_wrapper).await?; let stored_state = vec![0, 1, 2, 3, 4, 5, 6, 7]; resources.insert(VecB(stored_state.clone())); @@ -683,8 +683,8 @@ async fn resources_and_states_current_stored_and_goal( ( ParamsSpecs, Resources, - StatesCurrentStored, - StatesGoal, + StatesCurrentStored, + StatesGoal, ), VecCopyError, > { @@ -717,7 +717,7 @@ async fn resources_and_states_current_stored_and_goal( states_mut.insert_raw(>::id(item_wrapper).clone(), state); } - Into::::into(StatesCurrent::from(states_mut)) + Into::>::into(StatesCurrent::from(states_mut)) }; let states_goal = { let mut states_goal_mut = StatesMut::::new(); diff --git a/workspace_tests/src/rt_model/output/cli_output.rs b/workspace_tests/src/rt_model/output/cli_output.rs index 205fc383e..00c0be47c 100644 --- a/workspace_tests/src/rt_model/output/cli_output.rs +++ b/workspace_tests/src/rt_model/output/cli_output.rs @@ -38,7 +38,7 @@ async fn outputs_states_as_text() -> Result<(), Box> { let mut states = StatesMut::new(); states.insert(item_id!("item_0"), State::new("logical", 1.1)); states.insert(item_id!("item_1"), State::new(1u8, true)); - StatesCurrentStored::from(states) + StatesCurrentStored::::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; @@ -99,7 +99,7 @@ async fn outputs_states_as_text_colorized() -> Result<(), Box::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; @@ -174,7 +174,7 @@ async fn outputs_states_as_yaml() -> Result<(), Box> { let mut states = StatesMut::new(); states.insert(item_id!("item_0"), State::new("logical", 1.1)); states.insert(item_id!("item_1"), State::new(1u8, true)); - StatesCurrentStored::from(states) + StatesCurrentStored::::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; @@ -238,7 +238,7 @@ async fn outputs_states_as_json() -> Result<(), Box> { let mut states = StatesMut::new(); states.insert(item_id!("item_0"), State::new("logical", 1.1)); states.insert(item_id!("item_1"), State::new(1u8, true)); - StatesCurrentStored::from(states) + StatesCurrentStored::::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; diff --git a/workspace_tests/src/rt_model/states_serializer.rs b/workspace_tests/src/rt_model/states_serializer.rs index 7203e7ccd..2a1c0ec1c 100644 --- a/workspace_tests/src/rt_model/states_serializer.rs +++ b/workspace_tests/src/rt_model/states_serializer.rs @@ -36,7 +36,7 @@ async fn serialize() -> Result<(), Box> { let mut states_mut = StatesMut::new(); states_mut.insert(item_one.clone(), VecCopyState::from(vec![1u8])); states_mut.insert(item_two.clone(), MockState(2u8)); - StatesCurrentStored::from(states_mut) + StatesCurrentStored::::from(states_mut) }; StatesSerializer::::serialize( &storage, @@ -83,7 +83,7 @@ async fn deserialize_stored() -> Result<(), Box> { let mut states_mut = StatesMut::new(); states_mut.insert(item_one.clone(), VecCopyState::from(vec![1u8])); states_mut.insert(item_two.clone(), MockState(2u8)); - StatesCurrentStored::from(states_mut) + StatesCurrentStored::::from(states_mut) }; let mut states_type_reg = TypeReg::new_typed(); states_type_reg.register::(item_one.clone()); diff --git a/workspace_tests/src/vec_copy_item.rs b/workspace_tests/src/vec_copy_item.rs index 6bf943378..4927e5915 100644 --- a/workspace_tests/src/vec_copy_item.rs +++ b/workspace_tests/src/vec_copy_item.rs @@ -208,8 +208,10 @@ impl Item for VecCopyItem { async fn setup(&self, resources: &mut Resources) -> Result<(), VecCopyError> { let vec_b = { - let states_current_stored = - as Data>::borrow(Self::ID_DEFAULT, resources); + let states_current_stored = > as Data>::borrow( + Self::ID_DEFAULT, + resources, + ); let vec_copy_state_current_stored: Option<&'_ VecCopyState> = states_current_stored .as_ref() .and_then(|states_current_stored| states_current_stored.get(self.id())); From 34227b69f2900156a4bf9c4ad3892b86a26a5475 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Thu, 1 Feb 2024 18:31:57 +1300 Subject: [PATCH 4/7] Revert "A lot of string replacements to add ``." This reverts commit cd338c240c0fe83821629a2217aaa88f59d6f837. --- crate/cfg/src/accessors/stored.rs | 10 +- .../src/scopes/multi_profile_single_flow.rs | 11 +- .../src/scopes/single_profile_single_flow.rs | 4 +- crate/cmd_model/src/cmd_block_desc.rs | 2 +- crate/cmd_model/src/cmd_execution_error.rs | 28 ++--- crate/cmd_rt/src/cmd_block.rs | 27 +++-- crate/cmd_rt/src/cmd_block/cmd_block_error.rs | 8 +- .../cmd_rt/src/cmd_block/cmd_block_rt_box.rs | 3 +- .../cmd_rt/src/cmd_block/cmd_block_wrapper.rs | 4 +- .../cmd_execution_error_builder.rs | 20 ++-- crate/code_gen/src/cmd/impl_build.rs | 14 +-- crate/core/src/progress/progress_sender.rs | 11 +- .../src/progress/progress_update_and_id.rs | 7 +- crate/params/src/field_wise_spec_rt.rs | 8 +- crate/params/src/mapping_fn.rs | 8 +- crate/params/src/mapping_fn_impl.rs | 36 +++--- crate/params/src/params_resolve_error.rs | 10 +- crate/params/src/params_spec.rs | 22 ++-- crate/params/src/params_spec_fieldless.rs | 22 ++-- crate/params/src/params_specs.rs | 35 +----- crate/params/src/value_resolution_ctx.rs | 6 +- crate/params/src/value_spec.rs | 22 ++-- crate/params/src/value_spec_rt.rs | 8 +- .../impl_field_wise_spec_rt_for_field_wise.rs | 8 +- ...ld_wise_spec_rt_for_field_wise_external.rs | 16 +-- .../src/impl_value_spec_rt_for_field_wise.rs | 8 +- .../resources/src/internal/state_diffs_mut.rs | 40 ++----- crate/resources/src/internal/states_mut.rs | 34 ++---- crate/resources/src/states.rs | 45 ++------ crate/resources/src/states/state_diffs.rs | 42 ++----- crate/resources/src/states/states_clean.rs | 2 +- crate/resources/src/states/states_cleaned.rs | 11 +- .../src/states/states_cleaned_dry.rs | 15 +-- crate/resources/src/states/states_current.rs | 17 +-- .../src/states/states_current_stored.rs | 17 +-- crate/resources/src/states/states_ensured.rs | 14 +-- .../src/states/states_ensured_dry.rs | 15 +-- crate/resources/src/states/states_goal.rs | 11 +- .../src/states/states_goal_stored.rs | 11 +- crate/resources/src/states/states_previous.rs | 11 +- crate/resources/src/states/states_serde.rs | 22 ++-- .../rt/src/cmd_blocks/apply_exec_cmd_block.rs | 28 ++--- .../apply_state_sync_check_cmd_block.rs | 60 +++++----- crate/rt/src/cmd_blocks/diff_cmd_block.rs | 14 +-- .../states_current_read_cmd_block.rs | 7 +- .../cmd_blocks/states_discover_cmd_block.rs | 18 +-- .../cmd_blocks/states_goal_read_cmd_block.rs | 6 +- crate/rt/src/cmds/clean_cmd.rs | 14 +-- crate/rt/src/cmds/ensure_cmd.rs | 38 +++--- crate/rt/src/cmds/states_current_read_cmd.rs | 25 ++-- .../cmds/states_current_stored_display_cmd.rs | 7 +- crate/rt/src/cmds/states_discover_cmd.rs | 71 ++++++------ crate/rt/src/cmds/states_goal_display_cmd.rs | 2 +- crate/rt/src/cmds/states_goal_read_cmd.rs | 13 +-- crate/rt_model/src/item_graph.rs | 7 +- crate/rt_model/src/item_rt.rs | 2 +- crate/rt_model/src/item_wrapper.rs | 38 +++--- crate/rt_model/src/states_serializer.rs | 37 +++--- workspace_tests/src/cfg/stored.rs | 14 +-- .../single_profile_single_flow_builder.rs | 10 +- .../cmd_execution_error_builder.rs | 24 ++-- workspace_tests/src/items/tar_x_item.rs | 2 +- workspace_tests/src/mock_item.rs | 6 +- workspace_tests/src/params/derive.rs | 16 +-- workspace_tests/src/params/mapping_fn_impl.rs | 38 +++--- workspace_tests/src/params/params_spec.rs | 108 +++++++++--------- .../src/params/params_spec_fieldless.rs | 80 ++++++------- .../src/params/value_resolution_ctx.rs | 14 +-- workspace_tests/src/params/value_spec.rs | 80 ++++++------- workspace_tests/src/resources/resources.rs | 4 +- workspace_tests/src/resources/state_diffs.rs | 2 +- .../resources/states/states_cleaned_dry.rs | 2 +- .../src/resources/states/states_current.rs | 2 +- .../resources/states/states_current_stored.rs | 2 +- .../src/resources/states/states_ensured.rs | 2 +- .../resources/states/states_ensured_dry.rs | 2 +- .../src/resources/states/states_goal.rs | 2 +- .../resources/states/states_goal_stored.rs | 2 +- .../src/resources/states/states_previous.rs | 2 +- .../src/rt/cmd_blocks/apply_exec_cmd_block.rs | 44 ++----- .../apply_state_sync_check_cmd_block.rs | 36 ++---- .../src/rt/cmd_blocks/diff_cmd_block.rs | 23 +--- .../states_clean_insertion_cmd_block.rs | 2 +- .../states_current_read_cmd_block.rs | 5 +- .../cmd_blocks/states_discover_cmd_block.rs | 9 +- .../cmd_blocks/states_goal_read_cmd_block.rs | 5 +- workspace_tests/src/rt/cmds/diff_cmd.rs | 8 +- workspace_tests/src/rt/cmds/ensure_cmd.rs | 12 +- .../src/rt/cmds/states_discover_cmd.rs | 4 +- workspace_tests/src/rt_model/item_wrapper.rs | 8 +- .../src/rt_model/output/cli_output.rs | 8 +- .../src/rt_model/states_serializer.rs | 4 +- workspace_tests/src/vec_copy_item.rs | 6 +- 93 files changed, 680 insertions(+), 960 deletions(-) diff --git a/crate/cfg/src/accessors/stored.rs b/crate/cfg/src/accessors/stored.rs index 852139988..30c3ae3db 100644 --- a/crate/cfg/src/accessors/stored.rs +++ b/crate/cfg/src/accessors/stored.rs @@ -20,8 +20,8 @@ use serde::Serialize; pub struct Stored<'borrow, ItemIdT, T> { /// ID of the item the state should be retrieved for. item_id: ItemIdT, - /// The borrowed `StatesCurrentStored`. - states_current_stored: Option>>, + /// The borrowed `StatesCurrentStored`. + states_current_stored: Option>, /// Marker. marker: PhantomData, } @@ -47,7 +47,7 @@ where fn borrow(item_id: &'borrow ItemIdT, resources: &'borrow Resources) -> Self { let states_current_stored = resources - .try_borrow::>() + .try_borrow::() .map_err(|borrow_fail| match borrow_fail { e @ BorrowFail::ValueNotFound => e, BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { @@ -70,7 +70,7 @@ impl<'borrow, ItemIdT, T> DataAccess for Stored<'borrow, ItemIdT, T> { Self: Sized, { let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::>()); + type_ids.push(TypeId::of::()); type_ids } @@ -88,7 +88,7 @@ impl<'borrow, ItemIdT, T> DataAccessDyn for Stored<'borrow, ItemIdT, T> { Self: Sized, { let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::>()); + type_ids.push(TypeId::of::()); type_ids } diff --git a/crate/cmd/src/scopes/multi_profile_single_flow.rs b/crate/cmd/src/scopes/multi_profile_single_flow.rs index b2d07cca2..764966d0c 100644 --- a/crate/cmd/src/scopes/multi_profile_single_flow.rs +++ b/crate/cmd/src/scopes/multi_profile_single_flow.rs @@ -32,7 +32,7 @@ use crate::ctx::CmdCtxTypes; /// | |- 🌊 deploy # ✅ can read `FlowId` /// | | |- 📝 flow_params.yaml # ✅ can read or write `FlowParams` /// | | |- 📋 states_goal.yaml # ✅ can read or write `StatesGoal` -/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` +/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` /// | | /// | |- 🌊 .. # ❌ cannot read or write other `Flow` information /// | @@ -124,7 +124,7 @@ where FlowParams<<::FlowParamsKMaybe as KeyMaybe>::Key>, >, /// Stored current states for each profile for the selected flow. - profile_to_states_current_stored: BTreeMap>>, + profile_to_states_current_stored: BTreeMap>, /// Type registry for each item's [`Params`]`::Spec`. /// /// This is used to deserialize [`ParamsSpecsFile`]. @@ -200,8 +200,7 @@ where FlowParams<<::FlowParamsKMaybe as KeyMaybe>::Key>, >, /// Stored current states for each profile for the selected flow. - pub profile_to_states_current_stored: - &'view BTreeMap>>, + pub profile_to_states_current_stored: &'view BTreeMap>, /// Type registry for each item's [`Params`]`::Spec`. /// /// This is used to deserialize [`ParamsSpecsFile`]. @@ -254,7 +253,7 @@ where <::FlowParamsKMaybe as KeyMaybe>::Key, >, >, - profile_to_states_current_stored: BTreeMap>>, + profile_to_states_current_stored: BTreeMap>, params_specs_type_reg: ParamsSpecsTypeReg, profile_to_params_specs: BTreeMap>, states_type_reg: StatesTypeReg, @@ -414,7 +413,7 @@ where /// flow. pub fn profile_to_states_current_stored( &self, - ) -> &BTreeMap>> { + ) -> &BTreeMap> { &self.profile_to_states_current_stored } diff --git a/crate/cmd/src/scopes/single_profile_single_flow.rs b/crate/cmd/src/scopes/single_profile_single_flow.rs index 0d29c7fcc..ea14e9979 100644 --- a/crate/cmd/src/scopes/single_profile_single_flow.rs +++ b/crate/cmd/src/scopes/single_profile_single_flow.rs @@ -31,7 +31,7 @@ use crate::ctx::CmdCtxTypes; /// | |- 🌊 deploy # ✅ can read `FlowId` /// | | |- 📝 flow_params.yaml # ✅ can read or write `FlowParams` /// | | |- 📋 states_goal.yaml # ✅ can read or write `StatesGoal` -/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` +/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` /// | | /// | |- 🌊 .. # ❌ cannot read or write other `Flow` information /// | @@ -133,7 +133,7 @@ where /// | |- 🌊 deploy # ✅ can read `FlowId` /// | | |- 📝 flow_params.yaml # ✅ can read or write `FlowParams` /// | | |- 📋 states_goal.yaml # ✅ can read or write `StatesGoal` -/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` +/// | | |- 📋 states_current.yaml # ✅ can read or write `StatesCurrentStored` /// | | /// | |- 🌊 .. # ❌ cannot read or write other `Flow` information /// | diff --git a/crate/cmd_model/src/cmd_block_desc.rs b/crate/cmd_model/src/cmd_block_desc.rs index b6d6e1f05..8598597b9 100644 --- a/crate/cmd_model/src/cmd_block_desc.rs +++ b/crate/cmd_model/src/cmd_block_desc.rs @@ -43,7 +43,7 @@ impl CmdBlockDesc { } /// Returns the short type names of `CmdBlock::InputT`, e.g. - /// `["States", "States"]`. + /// `["States", "States"]`. /// /// * If `InputT` is the unit struct `()`, this should be empty. /// * If `InputT` is a named struct, this should contain just one `String`. diff --git a/crate/cmd_model/src/cmd_execution_error.rs b/crate/cmd_model/src/cmd_execution_error.rs index ac33ab821..f58d7d18e 100644 --- a/crate/cmd_model/src/cmd_execution_error.rs +++ b/crate/cmd_model/src/cmd_execution_error.rs @@ -12,10 +12,10 @@ use crate::CmdBlockDesc; pub enum CmdExecutionError { /// Error fetching `CmdBlock::InputT` from `resources`. /// - /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, - /// StatesGoal)`, and `states_current` and `states_goal` are - /// inserted individually in `Resources`, then `CmdBlock::input_fetch` - /// should be implemented to call `Resources::remove` for each of them. + /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, StatesGoal)`, + /// and `states_current` and `states_goal` are inserted individually in + /// `Resources`, then `CmdBlock::input_fetch` should be implemented to call + /// `Resources::remove` for each of them. #[error( "Error in `CmdExecution` or `CmdBlock` logic, usually due to incorrect `Resource` insertion or removal." )] @@ -44,23 +44,23 @@ pub enum CmdExecutionError { /// /// ```yaml /// CmdExecution: - /// ExecutionOutcome: (States, States, States) + /// ExecutionOutcome: (States, States, States) /// CmdBlocks: /// - StatesCurrentReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesGoalReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesDiscoverCmdBlock: /// Input: () - /// Outcome: (States, States) + /// Outcome: (States, States) /// - ApplyStateSyncCheckCmdBlock: - /// Input: (States, States, States, States) - /// Outcome: (States, States, States, States) + /// Input: (States, States, States, States) + /// Outcome: (States, States, States, States) /// - ApplyExecCmdBlock: - /// Input: (States, States) - /// Outcome: (States, States, States) + /// Input: (States, States) + /// Outcome: (States, States, States) /// ``` #[cfg(feature = "error_reporting")] #[source_code] diff --git a/crate/cmd_rt/src/cmd_block.rs b/crate/cmd_rt/src/cmd_block.rs index 5d46496e1..06abda006 100644 --- a/crate/cmd_rt/src/cmd_block.rs +++ b/crate/cmd_rt/src/cmd_block.rs @@ -48,8 +48,7 @@ pub trait CmdBlock: Debug { /// /// `CmdBlock` uses the `AppError` and `ParamsKeys` associated type. type CmdCtxTypes: CmdCtxTypesConstrained; - /// Outcome type of the command block, e.g. `(StatesCurrent, - /// StatesGoal)`. + /// Outcome type of the command block, e.g. `(StatesCurrent, StatesGoal)`. type Outcome: Debug + Send + Sync + 'static; /// Input type of the command block, e.g. `StatesCurrent`. type InputT: Resource + 'static; @@ -92,20 +91,20 @@ pub trait CmdBlock: Debug { /// Within the `peace` framework: /// /// ```rust,ignore - /// // type InputT = (StatesCurrent, StatesGoal); + /// // type InputT = (StatesCurrent, StatesGoal); /// - /// vec![tynm::type_name::>(), - /// tynm::type_name::>()] + /// vec![tynm::type_name::(), + /// tynm::type_name::()] /// ``` /// /// Outside the `peace` framework: /// /// ```rust,ignore - /// // type InputT = (StatesCurrent, StatesGoal); + /// // type InputT = (StatesCurrent, StatesGoal); /// /// vec![ - /// peace::cmd_rt::tynm::type_name::>(), - /// peace::cmd_rt::tynm::type_name::>(), + /// peace::cmd_rt::tynm::type_name::(), + /// peace::cmd_rt::tynm::type_name::(), /// ] /// ``` fn input_type_names(&self) -> Vec { @@ -141,20 +140,20 @@ pub trait CmdBlock: Debug { /// Within the `peace` framework: /// /// ```rust,ignore - /// // type Outcome = (StatesCurrent, StatesGoal); + /// // type Outcome = (StatesCurrent, StatesGoal); /// - /// vec![tynm::type_name::>(), - /// tynm::type_name::>()] + /// vec![tynm::type_name::(), + /// tynm::type_name::()] /// ``` /// /// Outside the `peace` framework: /// /// ```rust,ignore - /// // type Outcome = (StatesCurrent, StatesGoal); + /// // type Outcome = (StatesCurrent, StatesGoal); /// /// vec![ - /// peace::cmd_rt::tynm::type_name::>(), - /// peace::cmd_rt::tynm::type_name::>(), + /// peace::cmd_rt::tynm::type_name::(), + /// peace::cmd_rt::tynm::type_name::(), /// ] /// ``` fn outcome_type_names(&self) -> Vec { diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs index b22e239d2..896c6612a 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs @@ -19,10 +19,10 @@ where { /// Error fetching `CmdBlock::InputT` from `resources`. /// - /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, - /// StatesGoal)`, and `states_current` and `states_goal` are - /// inserted individually in `Resources`, then `CmdBlock::input_fetch` - /// should be implemented to call `Resources::remove` for each of them. + /// If `CmdBlock::InputT` is a tuple, such as `(StatesCurrent, StatesGoal)`, + /// and `states_current` and `states_goal` are inserted individually in + /// `Resources`, then `CmdBlock::input_fetch` should be implemented to call + /// `Resources::remove` for each of them. #[error( "Failed to fetch `{input_name_short}` from `resource`s.", input_name_short = _0.resource_name_short diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs b/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs index 7d9ace11c..e3e1efb29 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_rt_box.rs @@ -8,8 +8,7 @@ use crate::CmdBlockRt; /// /// * `E`: Automation software error type. /// * `PKeys`: Types of params keys. -/// * `Outcome`: [`CmdBlock`] outcome type, e.g. `(StatesCurrent, -/// StatesGoal)`. +/// * `Outcome`: [`CmdBlock`] outcome type, e.g. `(StatesCurrent, StatesGoal)`. /// /// [`CmdBlock`]: crate::CmdBlock pub type CmdBlockRtBox<'types, CmdCtxTypesT, ExecutionOutcome> = Pin< diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs b/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs index 0227d04a3..12fb4483e 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_wrapper.rs @@ -143,8 +143,8 @@ where // If possible, `CmdBlock` outcomes with item errors need to be mapped to // the `CmdExecution` outcome type, so we still return the item errors. // - // e.g. `StatesCurrentMut` should be mapped into `StatesEnsured` when - // some items fail to be ensured. + // e.g. `StatesCurrentMut` should be mapped into `StatesEnsured` when some + // items fail to be ensured. // // Note, when discovering current and goal states for diffing, and an item // error occurs, mapping the partially accumulated `(StatesCurrentMut, diff --git a/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs b/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs index 5a1f59187..16d40029d 100644 --- a/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs +++ b/crate/cmd_rt/src/cmd_execution/cmd_execution_error_builder.rs @@ -28,23 +28,23 @@ impl CmdExecutionErrorBuilder { /// /// ```yaml /// CmdExecution: - /// ExecutionOutcome: (States, States, States) + /// ExecutionOutcome: (States, States, States) /// CmdBlocks: /// - StatesCurrentReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesGoalReadCmdBlock: - /// Input: States - /// Outcome: States + /// Input: States + /// Outcome: States /// - StatesDiscoverCmdBlock: /// Input: () - /// Outcome: (States, States) + /// Outcome: (States, States) /// - ApplyStateSyncCheckCmdBlock: - /// Input: (States, States, States, States) - /// Outcome: (States, States, States, States) + /// Input: (States, States, States, States) + /// Outcome: (States, States, States, States) /// - ApplyExecCmdBlock: - /// Input: (States, States) - /// Outcome: (States, States, States) + /// Input: (States, States) + /// Outcome: (States, States, States) /// ``` pub fn build<'types: 'f, 'f, ExecutionOutcome, CmdCtxTypesT, CmdBlockIterator>( cmd_blocks: CmdBlockIterator, diff --git a/crate/code_gen/src/cmd/impl_build.rs b/crate/code_gen/src/cmd/impl_build.rs index 6147999e8..d09d015ec 100644 --- a/crate/code_gen/src/cmd/impl_build.rs +++ b/crate/code_gen/src/cmd/impl_build.rs @@ -649,14 +649,14 @@ fn impl_build_for( // &states_current_file, // ) // .await? - // .map(Into::>::into); + // .map(Into::::into); // // Ok((profile.clone(), states_current_stored)) // }) // .try_collect::< // std::collections::BTreeMap< // peace_core::Profile, - // Option> + // Option // > // >() // .await?; @@ -715,7 +715,7 @@ fn impl_build_for( // &states_current_file, // ) // .await? - // .map(Into::>::into); + // .map(Into::::into); // if let Some(states_current_stored) = states_current_stored { // resources.insert(states_current_stored); // } @@ -1542,7 +1542,7 @@ fn states_and_params_read_and_pg_init(scope: Scope) -> proc_macro2::TokenStream Scope::MultiProfileSingleFlow => { // * Reads previous item params and stores them in a `Map`. // * Reads previously stored current states and stores them in a `Map>`. + // StatesCurrentStored>`. // // These are then held in the scope for easy access for consumers. quote! { @@ -1617,14 +1617,14 @@ fn states_and_params_read_and_pg_init(scope: Scope) -> proc_macro2::TokenStream &states_current_file, ) .await? - .map(Into::>::into); + .map(Into::::into); Ok((profile.clone(), states_current_stored)) }) .try_collect::< std::collections::BTreeMap< peace_core::Profile, - Option> + Option > >() .await?; @@ -1701,7 +1701,7 @@ fn states_and_params_read_and_pg_init(scope: Scope) -> proc_macro2::TokenStream &states_current_file, ) .await? - .map(Into::>::into); + .map(Into::::into); if let Some(states_current_stored) = states_current_stored { resources.insert(states_current_stored); } diff --git a/crate/core/src/progress/progress_sender.rs b/crate/core/src/progress/progress_sender.rs index 41194026e..f75c3469e 100644 --- a/crate/core/src/progress/progress_sender.rs +++ b/crate/core/src/progress/progress_sender.rs @@ -1,19 +1,22 @@ use tokio::sync::mpsc::Sender; -use crate::progress::{ - CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressUpdate, ProgressUpdateAndId, +use crate::{ + progress::{ + CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressUpdate, ProgressUpdateAndId, + }, + ItemIdT, }; /// Submits progress for an item's `ApplyFns::exec` method. #[derive(Clone, Copy, Debug)] -pub struct ProgressSender<'exec, ItemIdT> { +pub struct ProgressSender<'exec> { /// ID of the item this belongs to. item_id: &'exec ItemIdT, /// Channel sender to send progress updates to. progress_tx: &'exec Sender, } -impl<'exec, ItemIdT> ProgressSender<'exec, ItemIdT> { +impl<'exec> ProgressSender<'exec> { /// Returns a new `ProgressSender`. pub fn new(item_id: &'exec ItemIdT, progress_tx: &'exec Sender) -> Self { Self { diff --git a/crate/core/src/progress/progress_update_and_id.rs b/crate/core/src/progress/progress_update_and_id.rs index 115cf9315..8306f486b 100644 --- a/crate/core/src/progress/progress_update_and_id.rs +++ b/crate/core/src/progress/progress_update_and_id.rs @@ -1,10 +1,13 @@ use serde::{Deserialize, Serialize}; -use crate::progress::{ProgressMsgUpdate, ProgressUpdate}; +use crate::{ + progress::{ProgressMsgUpdate, ProgressUpdate}, + ItemIdT, +}; /// An item ID and its progress update. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct ProgressUpdateAndId { +pub struct ProgressUpdateAndId { /// ID of the item whose progress is updated. pub item_id: ItemIdT, /// Delta update for the progress tracker. diff --git a/crate/params/src/field_wise_spec_rt.rs b/crate/params/src/field_wise_spec_rt.rs index 0e81ef302..0a84bcca8 100644 --- a/crate/params/src/field_wise_spec_rt.rs +++ b/crate/params/src/field_wise_spec_rt.rs @@ -27,14 +27,14 @@ pub trait FieldWiseSpecRt: AnySpecRt { fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result; /// Resolves the values to construct the item `Params`. /// /// Values that are not present in `Resources` will be `None`. fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result; } diff --git a/crate/params/src/mapping_fn.rs b/crate/params/src/mapping_fn.rs index 292d9c4b9..8c4ac9c67 100644 --- a/crate/params/src/mapping_fn.rs +++ b/crate/params/src/mapping_fn.rs @@ -25,8 +25,8 @@ pub trait MappingFn: Debug + DataType { fn map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result; /// Maps data in resources to the output type. /// @@ -40,8 +40,8 @@ pub trait MappingFn: Debug + DataType { fn try_map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError>; /// Returns whether this mapping function actually holds the function logic. /// diff --git a/crate/params/src/mapping_fn_impl.rs b/crate/params/src/mapping_fn_impl.rs index c6d5d862e..028c77547 100644 --- a/crate/params/src/mapping_fn_impl.rs +++ b/crate/params/src/mapping_fn_impl.rs @@ -115,8 +115,8 @@ macro_rules! impl_mapping_fn_impl { pub fn map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { let fn_map = self.fn_map.as_ref().unwrap_or_else( #[cfg_attr(coverage_nightly, coverage(off))] || { @@ -144,7 +144,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::ApplyDry => { $(arg_resolve!(resources, value_resolution_ctx, ApplyDry, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -152,7 +152,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::Current => { $(arg_resolve!(resources, value_resolution_ctx, Current, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -160,7 +160,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::Goal => { $(arg_resolve!(resources, value_resolution_ctx, Goal, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -168,7 +168,7 @@ macro_rules! impl_mapping_fn_impl { ValueResolutionMode::Clean => { $(arg_resolve!(resources, value_resolution_ctx, Clean, $var, $Arg);)+ - fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { + fn_map($(&$var,)+).ok_or(ParamsResolveError::FromMap { value_resolution_ctx: value_resolution_ctx.clone(), from_type_name: tynm::type_name::<($($Arg,)+)>(), }) @@ -179,8 +179,8 @@ macro_rules! impl_mapping_fn_impl { pub fn try_map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { let fn_map = self.fn_map.as_ref().unwrap_or_else( #[cfg_attr(coverage_nightly, coverage(off))] || { @@ -271,16 +271,16 @@ macro_rules! impl_mapping_fn_impl { fn map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result<::Output, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result<::Output, ParamsResolveError> { MappingFnImpl::::map(self, resources, value_resolution_ctx) } fn try_map( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result::Output>, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result::Output>, ParamsResolveError> { MappingFnImpl::::try_map(self, resources, value_resolution_ctx) } @@ -326,13 +326,13 @@ macro_rules! arg_resolve { // by any item, or // * There is a bug in Peace. BorrowFail::ValueNotFound => { - return Err(ParamsResolveError::FromMap { + return Err(ParamsResolveError::FromMap { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); } BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -340,7 +340,7 @@ macro_rules! arg_resolve { }, }, BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -351,7 +351,7 @@ macro_rules! arg_resolve { BorrowedData::Marked(marked_data) => match marked_data.as_ref() { Some(data) => data, None => { - return Err(ParamsResolveError::FromMap { + return Err(ParamsResolveError::FromMap { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -392,7 +392,7 @@ macro_rules! try_arg_resolve { // * There is a bug in Peace. BorrowFail::ValueNotFound => return Ok(None), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); @@ -400,7 +400,7 @@ macro_rules! try_arg_resolve { }, }, BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - return Err(ParamsResolveError::FromMapBorrowConflict { + return Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx: $value_resolution_ctx.clone(), from_type_name: tynm::type_name::<$Arg>(), }); diff --git a/crate/params/src/params_resolve_error.rs b/crate/params/src/params_resolve_error.rs index 918375ae8..20b6997be 100644 --- a/crate/params/src/params_resolve_error.rs +++ b/crate/params/src/params_resolve_error.rs @@ -6,7 +6,7 @@ use crate::{FieldNameAndType, ValueResolutionCtx}; // struct, enum -- instead of assuming it's always a named fields struct. #[derive(Debug, thiserror::Error)] #[cfg_attr(feature = "error_reporting", derive(miette::Diagnostic))] -pub enum ParamsResolveError { +pub enum ParamsResolveError { /// Failed to resolve a field value from `resources`. #[cfg_attr( feature = "error_reporting", @@ -33,7 +33,7 @@ pub enum ParamsResolveError { .unwrap_or(value_resolution_ctx.params_type_name()))] InMemory { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, }, /// Failed to borrow a field value from `resources`. @@ -64,7 +64,7 @@ pub enum ParamsResolveError { ] InMemoryBorrowConflict { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, }, /// Failed to resolve a from value from `resources`. @@ -88,7 +88,7 @@ pub enum ParamsResolveError { )] FromMap { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, /// Name of the type from which to map the field value from. /// /// Corresponds to `U` in `Fn(&U) -> T`. @@ -112,7 +112,7 @@ pub enum ParamsResolveError { )] FromMapBorrowConflict { /// Hierarchy of fields traversed to resolve the value. - value_resolution_ctx: ValueResolutionCtx, + value_resolution_ctx: ValueResolutionCtx, /// Name of the type from which to map the field value from. /// /// Corresponds to `U` in `Fn(&U) -> T`. diff --git a/crate/params/src/params_spec.rs b/crate/params/src/params_spec.rs index b17f1bd09..583112806 100644 --- a/crate/params/src/params_spec.rs +++ b/crate/params/src/params_spec.rs @@ -140,18 +140,18 @@ where pub fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { match self { ParamsSpec::Value { value } => Ok(value.clone()), ParamsSpec::Stored | ParamsSpec::InMemory => match resources.try_borrow::() { Ok(value) => Ok((*value).clone()), Err(borrow_fail) => match borrow_fail { - BorrowFail::ValueNotFound => Err(ParamsResolveError::::InMemory { + BorrowFail::ValueNotFound => Err(ParamsResolveError::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::::InMemoryBorrowConflict { + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -167,8 +167,8 @@ where pub fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { match self { ParamsSpec::Value { value } => Ok(T::Partial::from((*value).clone())), ParamsSpec::Stored | ParamsSpec::InMemory => match resources.try_borrow::() { @@ -176,7 +176,7 @@ where Err(borrow_fail) => match borrow_fail { BorrowFail::ValueNotFound => Ok(T::Partial::default()), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::::InMemoryBorrowConflict { + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -268,16 +268,16 @@ where fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { ParamsSpec::::resolve(self, resources, value_resolution_ctx) } fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { ParamsSpec::::resolve_partial(self, resources, value_resolution_ctx) .map(T::try_from) .map(Result::ok) diff --git a/crate/params/src/params_spec_fieldless.rs b/crate/params/src/params_spec_fieldless.rs index e741e7409..f71a8b944 100644 --- a/crate/params/src/params_spec_fieldless.rs +++ b/crate/params/src/params_spec_fieldless.rs @@ -118,19 +118,19 @@ where pub fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { match self { ParamsSpecFieldless::Value { value } => Ok(value.clone()), ParamsSpecFieldless::Stored | ParamsSpecFieldless::InMemory => { match resources.try_borrow::() { Ok(value) => Ok((*value).clone()), Err(borrow_fail) => match borrow_fail { - BorrowFail::ValueNotFound => Err(ParamsResolveError::::InMemory { + BorrowFail::ValueNotFound => Err(ParamsResolveError::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::::InMemoryBorrowConflict { + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -146,8 +146,8 @@ where pub fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { match self { ParamsSpecFieldless::Value { value } => Ok(T::Partial::from((*value).clone())), ParamsSpecFieldless::Stored | ParamsSpecFieldless::InMemory => { @@ -156,7 +156,7 @@ where Err(borrow_fail) => match borrow_fail { BorrowFail::ValueNotFound => Ok(T::Partial::default()), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::::InMemoryBorrowConflict { + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -230,16 +230,16 @@ where fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { ParamsSpecFieldless::::resolve(self, resources, value_resolution_ctx) } fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { ParamsSpecFieldless::::resolve_partial(self, resources, value_resolution_ctx) .map(T::try_from) .map(Result::ok) diff --git a/crate/params/src/params_specs.rs b/crate/params/src/params_specs.rs index 0c94e86c4..76d3d06ad 100644 --- a/crate/params/src/params_specs.rs +++ b/crate/params/src/params_specs.rs @@ -24,16 +24,11 @@ use crate::AnySpecRtBoxed; /// /// The information may not be of the same type across flows, as flows are /// different in what they are doing. -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug, Default, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct ParamsSpecs(TypeMap) -where - ItemIdT: ItemId; +pub struct ParamsSpecs(TypeMap); -impl ParamsSpecs -where - ItemIdT: ItemId, -{ +impl ParamsSpecs { /// Returns a new `ParamsSpecs` map. pub fn new() -> Self { Self::default() @@ -54,19 +49,7 @@ where } } -impl Default for ParamsSpecs -where - ItemIdT: ItemId, -{ - fn default() -> Self { - Self(TypeMap::default()) - } -} - -impl Deref for ParamsSpecs -where - ItemIdT: ItemId, -{ +impl Deref for ParamsSpecs { type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -74,19 +57,13 @@ where } } -impl DerefMut for ParamsSpecs -where - ItemIdT: ItemId, -{ +impl DerefMut for ParamsSpecs { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl From> for ParamsSpecs -where - ItemIdT: ItemId, -{ +impl From> for ParamsSpecs { fn from(type_map: TypeMap) -> Self { Self(type_map) } diff --git a/crate/params/src/value_resolution_ctx.rs b/crate/params/src/value_resolution_ctx.rs index d5f0ab320..f9c753345 100644 --- a/crate/params/src/value_resolution_ctx.rs +++ b/crate/params/src/value_resolution_ctx.rs @@ -6,7 +6,7 @@ use crate::{FieldNameAndType, ValueResolutionMode}; /// Collects information about how a value is resolved. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct ValueResolutionCtx { +pub struct ValueResolutionCtx { /// When resolving `Value`s, whether to look up `Current` or /// `Goal`. value_resolution_mode: ValueResolutionMode, @@ -18,7 +18,7 @@ pub struct ValueResolutionCtx { resolution_chain: Vec, } -impl ValueResolutionCtx { +impl ValueResolutionCtx { pub fn new( value_resolution_mode: ValueResolutionMode, item_id: ItemIdT, @@ -59,7 +59,7 @@ impl ValueResolutionCtx { } } -impl fmt::Display for ValueResolutionCtx { +impl fmt::Display for ValueResolutionCtx { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let params_type_name = self.params_type_name(); write!(f, "{params_type_name} {{")?; diff --git a/crate/params/src/value_spec.rs b/crate/params/src/value_spec.rs index e84e28d52..86b042248 100644 --- a/crate/params/src/value_spec.rs +++ b/crate/params/src/value_spec.rs @@ -116,18 +116,18 @@ where pub fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { match self { ValueSpec::Value { value } => Ok(value.clone()), ValueSpec::Stored | ValueSpec::InMemory => match resources.try_borrow::() { Ok(value) => Ok((*value).clone()), Err(borrow_fail) => match borrow_fail { - BorrowFail::ValueNotFound => Err(ParamsResolveError::::InMemory { + BorrowFail::ValueNotFound => Err(ParamsResolveError::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::::InMemoryBorrowConflict { + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -140,8 +140,8 @@ where pub fn resolve_partial( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { match self { ValueSpec::Value { value } => Ok(Some((*value).clone())), ValueSpec::Stored | ValueSpec::InMemory => match resources.try_borrow::() { @@ -149,7 +149,7 @@ where Err(borrow_fail) => match borrow_fail { BorrowFail::ValueNotFound => Ok(None), BorrowFail::BorrowConflictImm | BorrowFail::BorrowConflictMut => { - Err(ParamsResolveError::::InMemoryBorrowConflict { + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -206,16 +206,16 @@ where fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result { ValueSpec::::resolve(self, resources, value_resolution_ctx) } fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError> { + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError> { ValueSpec::::resolve_partial(self, resources, value_resolution_ctx) } } diff --git a/crate/params/src/value_spec_rt.rs b/crate/params/src/value_spec_rt.rs index 7d9142169..b996855ad 100644 --- a/crate/params/src/value_spec_rt.rs +++ b/crate/params/src/value_spec_rt.rs @@ -23,14 +23,14 @@ pub trait ValueSpecRt: AnySpecRt { fn resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result; /// Resolves the value from resources, returning `None` if it is not /// present. fn try_resolve( &self, resources: &Resources, - value_resolution_ctx: &mut ValueResolutionCtx, - ) -> Result, ParamsResolveError>; + value_resolution_ctx: &mut ValueResolutionCtx, + ) -> Result, ParamsResolveError>; } diff --git a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs index 11bce9943..447eacf24 100644 --- a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs +++ b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise.rs @@ -102,16 +102,16 @@ pub fn impl_field_wise_spec_rt_for_field_wise( fn resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { #resolve_body } fn resolve_partial( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { #resolve_partial_body } } diff --git a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs index 8b50af625..17ae4a88b 100644 --- a/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs +++ b/crate/params_derive/src/impl_field_wise_spec_rt_for_field_wise_external.rs @@ -23,8 +23,8 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( fn resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { if let Some(params) = self.0.as_ref() { Ok(params.clone()) } else { @@ -32,13 +32,13 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( Ok(t) => Ok((&*t).clone()), Err(borrow_fail) => match borrow_fail { #peace_resources_path::BorrowFail::ValueNotFound => { - Err(#peace_params_path::ParamsResolveError::::InMemory { + Err(#peace_params_path::ParamsResolveError::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }) } #peace_resources_path::BorrowFail::BorrowConflictImm | #peace_resources_path::BorrowFail::BorrowConflictMut => { - Err(#peace_params_path::ParamsResolveError::::InMemoryBorrowConflict { + Err(#peace_params_path::ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } @@ -50,8 +50,8 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( fn resolve_partial( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_partial_name #ty_generics, #peace_params_path::ParamsResolveError> { if let Some(params) = self.0.as_ref() { Ok(params.clone().into()) } else { @@ -59,13 +59,13 @@ pub fn impl_field_wise_spec_rt_for_field_wise_external( Ok(t) => Ok((&*t).clone().into()), Err(borrow_fail) => match borrow_fail { #peace_resources_path::BorrowFail::ValueNotFound => { - Err(#peace_params_path::ParamsResolveError::::InMemory { + Err(#peace_params_path::ParamsResolveError::InMemory { value_resolution_ctx: value_resolution_ctx.clone(), }) } #peace_resources_path::BorrowFail::BorrowConflictImm | #peace_resources_path::BorrowFail::BorrowConflictMut => { - Err(#peace_params_path::ParamsResolveError::::InMemoryBorrowConflict { + Err(#peace_params_path::ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx: value_resolution_ctx.clone(), }) } diff --git a/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs b/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs index 15d0064ea..3334f67e0 100644 --- a/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs +++ b/crate/params_derive/src/impl_value_spec_rt_for_field_wise.rs @@ -100,16 +100,16 @@ pub fn impl_value_spec_rt_for_field_wise( fn resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result<#params_name #ty_generics, #peace_params_path::ParamsResolveError> { #resolve_body } fn try_resolve( &self, resources: &#peace_resources_path::Resources<#peace_resources_path::resources::ts::SetUp>, - value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, - ) -> Result, #peace_params_path::ParamsResolveError> { + value_resolution_ctx: &mut #peace_params_path::ValueResolutionCtx, + ) -> Result, #peace_params_path::ParamsResolveError> { #try_resolve_body } } diff --git a/crate/resources/src/internal/state_diffs_mut.rs b/crate/resources/src/internal/state_diffs_mut.rs index f9868946a..347769299 100644 --- a/crate/resources/src/internal/state_diffs_mut.rs +++ b/crate/resources/src/internal/state_diffs_mut.rs @@ -14,15 +14,10 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// /// [`StateDiffs`]: crate::StateDiffs /// [`Resources`]: crate::Resources -#[derive(Debug, Serialize)] -pub struct StateDiffsMut(TypeMap) -where - ItemIdT: ItemId; +#[derive(Debug, Default, Serialize)] +pub struct StateDiffsMut(TypeMap); -impl StateDiffsMut -where - ItemIdT: ItemId, -{ +impl StateDiffsMut { /// Returns a new `StateDiffsMut` map. pub fn new() -> Self { Self::default() @@ -42,19 +37,7 @@ where } } -impl Default for StateDiffsMut -where - ItemIdT: ItemId, -{ - fn default() -> Self { - Self(TypeMap::default()) - } -} - -impl Deref for StateDiffsMut -where - ItemIdT: ItemId, -{ +impl Deref for StateDiffsMut { type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -62,28 +45,19 @@ where } } -impl DerefMut for StateDiffsMut -where - ItemIdT: ItemId, -{ +impl DerefMut for StateDiffsMut { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl From> for StateDiffsMut -where - ItemIdT: ItemId, -{ +impl From> for StateDiffsMut { fn from(type_map: TypeMap) -> Self { Self(type_map) } } -impl Extend<(ItemIdT, BoxDtDisplay)> for StateDiffsMut -where - ItemIdT: ItemId, -{ +impl Extend<(ItemIdT, BoxDtDisplay)> for StateDiffsMut { fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state_diff)| { self.insert_raw(item_id, state_diff); diff --git a/crate/resources/src/internal/states_mut.rs b/crate/resources/src/internal/states_mut.rs index befcf571b..089ef86ac 100644 --- a/crate/resources/src/internal/states_mut.rs +++ b/crate/resources/src/internal/states_mut.rs @@ -26,14 +26,9 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// [`StatesCurrent`]: crate::StatesCurrent /// [`StatesRw`]: crate::StatesRw #[derive(Debug, Serialize)] -pub struct StatesMut(TypeMap, PhantomData) -where - ItemIdT: ItemId; +pub struct StatesMut(TypeMap, PhantomData); -impl StatesMut -where - ItemIdT: ItemId, -{ +impl StatesMut { /// Returns a new `StatesMut` map. pub fn new() -> Self { Self::default() @@ -53,19 +48,13 @@ where } } -impl Default for StatesMut -where - ItemIdT: ItemId, -{ +impl Default for StatesMut { fn default() -> Self { Self(TypeMap::default(), PhantomData) } } -impl Deref for StatesMut -where - ItemIdT: ItemId, -{ +impl Deref for StatesMut { type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -73,28 +62,19 @@ where } } -impl DerefMut for StatesMut -where - ItemIdT: ItemId, -{ +impl DerefMut for StatesMut { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl From> for StatesMut -where - ItemIdT: ItemId, -{ +impl From> for StatesMut { fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } -impl Extend<(ItemIdT, BoxDtDisplay)> for StatesMut -where - ItemIdT: ItemId, -{ +impl Extend<(ItemIdT, BoxDtDisplay)> for StatesMut { fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state)| { self.insert_raw(item_id, state); diff --git a/crate/resources/src/states.rs b/crate/resources/src/states.rs index 7c0332ae7..de5249eae 100644 --- a/crate/resources/src/states.rs +++ b/crate/resources/src/states.rs @@ -145,17 +145,12 @@ mod states_serde; /// [`flatten()`]: std::option::Option::flatten #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct States( +pub struct States( pub(crate) TypeMap, pub(crate) PhantomData, -) -where - ItemIdT: ItemId; - -impl States -where - ItemIdT: ItemId, -{ +); + +impl States { /// Returns a new `States` map. pub fn new() -> Self { Self::default() @@ -175,10 +170,7 @@ where } } -impl Clone for States -where - ItemIdT: ItemId, -{ +impl Clone for States { fn clone(&self) -> Self { let mut clone = Self(TypeMap::with_capacity_typed(self.0.len()), PhantomData); clone.0.extend( @@ -191,19 +183,13 @@ where } } -impl Default for States -where - ItemIdT: ItemId, -{ +impl Default for States { fn default() -> Self { Self(TypeMap::default(), PhantomData) } } -impl Deref for States -where - ItemIdT: ItemId, -{ +impl Deref for States { type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -211,29 +197,20 @@ where } } -impl From> for States -where - ItemIdT: ItemId, -{ +impl From> for States { fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } -impl From> for States -where - ItemIdT: ItemId, -{ - fn from(states_mut: StatesMut) -> Self { +impl From> for States { + fn from(states_mut: StatesMut) -> Self { Self(states_mut.into_inner(), PhantomData) } } #[peace_fmt::async_trait(?Send)] -impl Presentable for States -where - ItemIdT: ItemId + Presentable, -{ +impl Presentable for States { async fn present<'output, PR>(&self, presenter: &mut PR) -> Result<(), PR::Error> where PR: Presenter<'output>, diff --git a/crate/resources/src/states/state_diffs.rs b/crate/resources/src/states/state_diffs.rs index 039f5c6ec..0bc95c56c 100644 --- a/crate/resources/src/states/state_diffs.rs +++ b/crate/resources/src/states/state_diffs.rs @@ -19,24 +19,10 @@ use crate::internal::StateDiffsMut; /// /// [`External`]: peace_cfg::state::External /// [`Resources`]: crate::Resources -#[derive(Debug, Serialize)] -pub struct StateDiffs(TypeMap) -where - ItemIdT: ItemId; +#[derive(Debug, Default, Serialize)] +pub struct StateDiffs(TypeMap); -impl Default for StateDiffs -where - ItemIdT: ItemId, -{ - fn default() -> Self { - Self(TypeMap::::default()) - } -} - -impl StateDiffs -where - ItemIdT: ItemId, -{ +impl StateDiffs { /// Returns a new `StateDiffs` map. pub fn new() -> Self { Self::default() @@ -56,10 +42,7 @@ where } } -impl Deref for StateDiffs -where - ItemIdT: ItemId, -{ +impl Deref for StateDiffs { type Target = TypeMap; fn deref(&self) -> &Self::Target { @@ -67,29 +50,20 @@ where } } -impl From> for StateDiffs -where - ItemIdT: ItemId, -{ +impl From> for StateDiffs { fn from(type_map: TypeMap) -> Self { Self(type_map) } } -impl From> for StateDiffs -where - ItemIdT: ItemId, -{ - fn from(state_diffs_mut: StateDiffsMut) -> Self { +impl From for StateDiffs { + fn from(state_diffs_mut: StateDiffsMut) -> Self { Self(state_diffs_mut.into_inner()) } } #[peace_fmt::async_trait(?Send)] -impl Presentable for StateDiffs -where - ItemIdT: ItemId + Presentable, -{ +impl Presentable for StateDiffs { async fn present<'output, PR>(&self, presenter: &mut PR) -> Result<(), PR::Error> where PR: Presenter<'output>, diff --git a/crate/resources/src/states/states_clean.rs b/crate/resources/src/states/states_clean.rs index 174511867..e619b2a3c 100644 --- a/crate/resources/src/states/states_clean.rs +++ b/crate/resources/src/states/states_clean.rs @@ -13,4 +13,4 @@ use crate::states::{ts::Clean, States}; /// /// You may reference [`StatesClean`] after `CleanCmd::exec` has been run, /// unless it is the `ExecutionOutcome`. -pub type StatesClean = States; +pub type StatesClean = States; diff --git a/crate/resources/src/states/states_cleaned.rs b/crate/resources/src/states/states_cleaned.rs index b3b3774b5..26b13e4ce 100644 --- a/crate/resources/src/states/states_cleaned.rs +++ b/crate/resources/src/states/states_cleaned.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ts::Cleaned, States, StatesCurrent}; /// Cleaned `State`s for all `Item`s. `TypeMap` newtype. @@ -16,13 +14,10 @@ use crate::states::{ts::Cleaned, States, StatesCurrent}; /// /// You may reference [`StatesCleaned`] after `CleanCmd::exec` has been run, /// unless it is the `ExecutionOutcome`. -pub type StatesCleaned = States; +pub type StatesCleaned = States; -impl From> for StatesCleaned -where - ItemIdT: ItemId, -{ - fn from(states: StatesCurrent) -> Self { +impl From for StatesCleaned { + fn from(states: StatesCurrent) -> Self { Self(states.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_cleaned_dry.rs b/crate/resources/src/states/states_cleaned_dry.rs index 0a4c0d643..97f235eed 100644 --- a/crate/resources/src/states/states_cleaned_dry.rs +++ b/crate/resources/src/states/states_cleaned_dry.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ts::CleanedDry, States, StatesCurrent}; /// Dry-run ensured `State`s for all `Item`s. @@ -11,17 +9,14 @@ use crate::states::{ts::CleanedDry, States, StatesCurrent}; /// /// # Implementors /// -/// You may reference [`StatesCleanedDry`] after `CleanCmd::exec_dry` -/// has been run. +/// You may reference [`StatesCleanedDry`] after `CleanCmd::exec_dry` has been +/// run. /// /// [`Data`]: peace_data::Data -pub type StatesCleanedDry = States; +pub type StatesCleanedDry = States; -impl From> for StatesCleanedDry -where - ItemIdT: ItemId, -{ - fn from(states: StatesCurrent) -> Self { +impl From for StatesCleanedDry { + fn from(states: StatesCurrent) -> Self { Self(states.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_current.rs b/crate/resources/src/states/states_current.rs index d891b7e4d..57788c3ad 100644 --- a/crate/resources/src/states/states_current.rs +++ b/crate/resources/src/states/states_current.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ ts::{Current, CurrentStored}, States, @@ -11,8 +9,8 @@ use crate::states::{ /// /// This is strictly only present when the [`States`] are discovered in the /// current execution. `States` read from the [`StatesCurrentFile`] are -/// inserted into [`Resources`] as [`StatesCurrentStored`], as those -/// discovered states may be out of date with the actual. +/// inserted into [`Resources`] as [`StatesCurrentStored`], as those discovered +/// states may be out of date with the actual. /// /// # Implementors /// @@ -49,14 +47,11 @@ use crate::states::{ /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources /// [`StatesCurrentFile`] crate::paths::StatesCurrentFile -/// [`StatesCurrentStored`]: crate::states::StatesCurrentStored -pub type StatesCurrent = States; +/// [`StatesCurrentStored`]: crate::states::StatesCurrentStored +pub type StatesCurrent = States; -impl From> for States -where - ItemIdT: ItemId, -{ - fn from(states_current_stored: States) -> Self { +impl From> for States { + fn from(states_current_stored: States) -> Self { let States(type_map, PhantomData) = states_current_stored; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_current_stored.rs b/crate/resources/src/states/states_current_stored.rs index a0aa23b3f..5b3b8f5a8 100644 --- a/crate/resources/src/states/states_current_stored.rs +++ b/crate/resources/src/states/states_current_stored.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ ts::{Current, CurrentStored}, States, @@ -47,20 +45,17 @@ use crate::states::{ /// } /// ``` /// -/// You may reference [`StatesCurrentStored`] in `ApplyFns::Data` for -/// reading. It is not mutable as `StatesCurrentStored` must remain -/// unchanged so that all `Item`s operate over consistent data. +/// You may reference [`StatesCurrentStored`] in `ApplyFns::Data` for reading. +/// It is not mutable as `StatesCurrentStored` must remain unchanged so that all +/// `Item`s operate over consistent data. /// /// [`StatesCurrentFile`]: crate::paths::StatesCurrentFile /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources -pub type StatesCurrentStored = States; +pub type StatesCurrentStored = States; -impl From> for States -where - ItemIdT: ItemId, -{ - fn from(states_current: States) -> Self { +impl From> for States { + fn from(states_current: States) -> Self { let States(type_map, PhantomData) = states_current; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_ensured.rs b/crate/resources/src/states/states_ensured.rs index 978a32995..c97ef2545 100644 --- a/crate/resources/src/states/states_ensured.rs +++ b/crate/resources/src/states/states_ensured.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ts::Ensured, States, StatesCurrent}; /// Ensured `State`s for all `Item`s. `TypeMap` newtype. @@ -10,17 +8,13 @@ use crate::states::{ts::Ensured, States, StatesCurrent}; /// /// # Implementors /// -/// You may reference [`StatesEnsured`] after `EnsureCmd::exec` has -/// been run. +/// You may reference [`StatesEnsured`] after `EnsureCmd::exec` has been run. /// /// [`Data`]: peace_data::Data -pub type StatesEnsured = States; +pub type StatesEnsured = States; -impl From> for StatesEnsured -where - ItemIdT: ItemId, -{ - fn from(states_current: StatesCurrent) -> Self { +impl From for StatesEnsured { + fn from(states_current: StatesCurrent) -> Self { Self(states_current.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_ensured_dry.rs b/crate/resources/src/states/states_ensured_dry.rs index 1450d30e8..af7ed3307 100644 --- a/crate/resources/src/states/states_ensured_dry.rs +++ b/crate/resources/src/states/states_ensured_dry.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ts::EnsuredDry, States, StatesCurrent}; /// Dry-run ensured `State`s for all `Item`s. @@ -11,17 +9,14 @@ use crate::states::{ts::EnsuredDry, States, StatesCurrent}; /// /// # Implementors /// -/// You may reference [`StatesEnsuredDry`] after `EnsureCmd::exec_dry` -/// has been run. +/// You may reference [`StatesEnsuredDry`] after `EnsureCmd::exec_dry` has been +/// run. /// /// [`Data`]: peace_data::Data -pub type StatesEnsuredDry = States; +pub type StatesEnsuredDry = States; -impl From> for StatesEnsuredDry -where - ItemIdT: ItemId, -{ - fn from(states_current: StatesCurrent) -> Self { +impl From for StatesEnsuredDry { + fn from(states_current: StatesCurrent) -> Self { Self(states_current.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_goal.rs b/crate/resources/src/states/states_goal.rs index e893606a0..e5f0ef8f3 100644 --- a/crate/resources/src/states/states_goal.rs +++ b/crate/resources/src/states/states_goal.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ ts::{Goal, GoalStored}, States, @@ -47,13 +45,10 @@ use crate::states::{ /// /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources -pub type StatesGoal = States; +pub type StatesGoal = States; -impl From> for States -where - ItemIdT: ItemId, -{ - fn from(states_goal_stored: States) -> Self { +impl From> for States { + fn from(states_goal_stored: States) -> Self { let States(type_map, PhantomData) = states_goal_stored; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_goal_stored.rs b/crate/resources/src/states/states_goal_stored.rs index f6a84522c..4e366efa0 100644 --- a/crate/resources/src/states/states_goal_stored.rs +++ b/crate/resources/src/states/states_goal_stored.rs @@ -1,7 +1,5 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ ts::{Goal, GoalStored}, States, @@ -23,13 +21,10 @@ use crate::states::{ /// [`StatesGoalFile`]: crate::paths::StatesGoalFile /// [`Data`]: peace_data::Data /// [`Resources`]: crate::Resources -pub type StatesGoalStored = States; +pub type StatesGoalStored = States; -impl From> for States -where - ItemIdT: ItemId, -{ - fn from(states_goal: States) -> Self { +impl From> for States { + fn from(states_goal: States) -> Self { let States(type_map, PhantomData) = states_goal; Self(type_map, PhantomData) diff --git a/crate/resources/src/states/states_previous.rs b/crate/resources/src/states/states_previous.rs index 830cb7638..35185845c 100644 --- a/crate/resources/src/states/states_previous.rs +++ b/crate/resources/src/states/states_previous.rs @@ -1,20 +1,15 @@ use std::marker::PhantomData; -use peace_core::ItemId; - use crate::states::{ts::Previous, States, StatesCurrent}; /// Previous `State`s for all `Item`s. /// /// This is present when an `ApplyCmd` (`EnsureCmd` or `CleanCmd`) is run, /// whereby the current states have changed to the newly ensured states. -pub type StatesPrevious = States; +pub type StatesPrevious = States; -impl From> for StatesPrevious -where - ItemIdT: ItemId, -{ - fn from(states_current: StatesCurrent) -> Self { +impl From for StatesPrevious { + fn from(states_current: StatesCurrent) -> Self { Self(states_current.into_inner(), PhantomData) } } diff --git a/crate/resources/src/states/states_serde.rs b/crate/resources/src/states/states_serde.rs index c3c7e1f30..c5aea647b 100644 --- a/crate/resources/src/states/states_serde.rs +++ b/crate/resources/src/states/states_serde.rs @@ -28,16 +28,12 @@ use type_reg::{ /// [`FromIterator::<(ItemIdT, Option)>::from_iter`]: std::iter::FromIterator #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct StatesSerde( - TypeMapOpt>, -) +pub struct StatesSerde(TypeMapOpt>) where - ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq; -impl StatesSerde +impl StatesSerde where - ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { /// Creates an empty `StatesSerde` map with the specified capacity. @@ -54,9 +50,8 @@ where } } -impl Clone for StatesSerde +impl Clone for StatesSerde where - ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { fn clone(&self) -> Self { @@ -71,9 +66,8 @@ where } } -impl Deref for StatesSerde +impl Deref for StatesSerde where - ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { type Target = TypeMapOpt>; @@ -83,9 +77,8 @@ where } } -impl FromIterator<(ItemIdT, Option)> for StatesSerde +impl FromIterator<(ItemIdT, Option)> for StatesSerde where - ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { fn from_iter)>>(iter: T) -> Self { @@ -99,10 +92,9 @@ where } } -impl From>> - for StatesSerde +impl From>> + for StatesSerde where - ItemIdT: ItemId, ValueT: Clone + Debug + PartialEq + Eq, { fn from(type_map_opt: TypeMapOpt>) -> Self { diff --git a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs index 9f1dda80c..0e776cce6 100644 --- a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs @@ -324,8 +324,8 @@ where mut states_target_mut: StatesMut, ) -> Result< ( - States, - States, + States, + States, IndexMap::AppError>, ), ::AppError, @@ -427,28 +427,24 @@ where StatesTs: StatesTsApplyExt + Debug + Send + Sync + 'static, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (StatesCurrent, States); - type Outcome = ( - StatesPrevious, - States, - States, - ); + type InputT = (StatesCurrent, States); + type Outcome = (StatesPrevious, States, States); fn input_fetch( &self, resources: &mut Resources, ) -> Result { - let states_current = resources.try_remove::>()?; + let states_current = resources.try_remove::()?; - let states_target = resources.try_remove::>()?; + let states_target = resources.try_remove::>()?; Ok((states_current, states_target)) } fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::>(), ] } @@ -461,9 +457,9 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -478,7 +474,7 @@ where > { let (states_current, states_target) = input; let (states_previous, states_applied_mut, states_target_mut) = { - let states_previous = StatesPrevious::::from(states_current.clone()); + let states_previous = StatesPrevious::from(states_current.clone()); // `Ensured`, `EnsuredDry`, `Cleaned`, `CleanedDry` states start as the current // state, and are altered. let states_applied_mut = diff --git a/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs b/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs index ae9ac4edf..98d5a52c2 100644 --- a/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/apply_state_sync_check_cmd_block.rs @@ -124,8 +124,8 @@ where { fn items_state_stored_stale( cmd_view: &SingleProfileSingleFlowView<'_, CmdCtxTypesT>, - states_stored: &States, - states_discovered: &States, + states_stored: &States, + states_discovered: &States, #[cfg(feature = "output_progress")] progress_tx: &Sender, ) -> Result::AppError> { let items_state_stored_stale = cmd_view.flow.graph().iter_insertion().try_fold( @@ -262,7 +262,7 @@ where CmdCtxTypesT: CmdCtxTypesConstrained, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (StatesCurrentStored, StatesCurrent); + type InputT = (StatesCurrentStored, StatesCurrent); type Outcome = Self::InputT; fn input_fetch( @@ -274,8 +274,8 @@ where fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -287,8 +287,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -336,7 +336,7 @@ where CmdCtxTypesT: CmdCtxTypesConstrained, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (StatesGoalStored, StatesGoal); + type InputT = (StatesGoalStored, StatesGoal); type Outcome = Self::InputT; fn input_fetch( @@ -348,8 +348,8 @@ where fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -361,8 +361,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -412,10 +412,10 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = ( - StatesCurrentStored, - StatesCurrent, - StatesGoalStored, - StatesGoal, + StatesCurrentStored, + StatesCurrent, + StatesGoalStored, + StatesGoal, ); type Outcome = Self::InputT; @@ -436,10 +436,10 @@ where fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -453,10 +453,10 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -548,18 +548,18 @@ enum OutcomeResult { fn input_fetch_current( resources: &mut Resources, -) -> Result<(StatesCurrentStored, StatesCurrent), ResourceFetchError> { - let states_current_stored = resources.try_remove::>()?; - let states_current = resources.try_remove::>()?; +) -> Result<(StatesCurrentStored, StatesCurrent), ResourceFetchError> { + let states_current_stored = resources.try_remove::()?; + let states_current = resources.try_remove::()?; Ok((states_current_stored, states_current)) } fn input_fetch_goal( resources: &mut Resources, -) -> Result<(StatesGoalStored, StatesGoal), ResourceFetchError> { - let states_goal_stored = resources.try_remove::>()?; - let states_goal = resources.try_remove::>()?; +) -> Result<(StatesGoalStored, StatesGoal), ResourceFetchError> { + let states_goal_stored = resources.try_remove::()?; + let states_goal = resources.try_remove::()?; Ok((states_goal_stored, states_goal)) } diff --git a/crate/rt/src/cmd_blocks/diff_cmd_block.rs b/crate/rt/src/cmd_blocks/diff_cmd_block.rs index 213857ab8..c6e656a9f 100644 --- a/crate/rt/src/cmd_blocks/diff_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/diff_cmd_block.rs @@ -119,23 +119,23 @@ where StatesTs1: Debug + Send + Sync + 'static, { type CmdCtxTypes = CmdCtxTypesT; - type InputT = (States, States); + type InputT = (States, States); type Outcome = (StateDiffs, Self::InputT); fn input_fetch( &self, resources: &mut Resources, ) -> Result { - let states_ts0 = resources.try_remove::>()?; - let states_ts1 = resources.try_remove::>()?; + let states_ts0 = resources.try_remove::>()?; + let states_ts1 = resources.try_remove::>()?; Ok((states_ts0, states_ts1)) } fn input_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } @@ -149,8 +149,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ tynm::type_name::(), - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::>(), + tynm::type_name::>(), ] } diff --git a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs index 96c92d44e..0c399b29c 100644 --- a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs @@ -20,7 +20,7 @@ cfg_if::cfg_if! { } } -/// Reads [`StatesCurrentStored`]s from storage. +/// Reads [`StatesCurrentStored`]s from storage. /// /// Either [`StatesDiscoverCmdBlock::current`] or /// [`StatesDiscoverCmdBlock::current_and_goal`] must have run prior to this @@ -42,8 +42,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, states_type_reg: &TypeReg, - ) -> Result, ::AppError> - { + ) -> Result::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); let storage = resources.borrow::(); @@ -80,7 +79,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = StatesCurrentStored; + type Outcome = StatesCurrentStored; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) diff --git a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs index d0746954d..3a4703f8b 100644 --- a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs @@ -264,7 +264,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = States; + type Outcome = States; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) @@ -352,7 +352,7 @@ where mut states_current_mut: StatesMut, ) -> Result< ( - States, + States, IndexMap::AppError>, ), ::AppError, @@ -407,7 +407,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = States; + type Outcome = States; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) @@ -495,7 +495,7 @@ where mut states_goal_mut: StatesMut, ) -> Result< ( - States, + States, IndexMap::AppError>, ), ::AppError, @@ -550,7 +550,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = (States, States); + type Outcome = (States, States); fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) @@ -568,8 +568,8 @@ where fn outcome_type_names(&self) -> Vec { vec![ - tynm::type_name::>(), - tynm::type_name::>(), + tynm::type_name::(), + tynm::type_name::(), ] } @@ -654,8 +654,8 @@ where mut states_goal_mut: StatesMut, ) -> Result< ( - States, - States, + States, + States, IndexMap::AppError>, ), ::AppError, diff --git a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs index c619a3e3e..bbd6cad9d 100644 --- a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs @@ -20,7 +20,7 @@ cfg_if::cfg_if! { } } -/// Reads [`StatesGoalStored`]s from storage. +/// Reads [`StatesGoalStored`]s from storage. /// /// Either [`StatesDiscoverCmdBlock::goal`] or /// [`StatesDiscoverCmdBlock::current_and_goal`] must have run prior to this @@ -42,7 +42,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, states_type_reg: &TypeReg, - ) -> Result, ::AppError> { + ) -> Result::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); let storage = resources.borrow::(); @@ -79,7 +79,7 @@ where { type CmdCtxTypes = CmdCtxTypesT; type InputT = (); - type Outcome = StatesGoalStored; + type Outcome = StatesGoalStored; fn input_fetch(&self, _resources: &mut Resources) -> Result<(), ResourceFetchError> { Ok(()) diff --git a/crate/rt/src/cmds/clean_cmd.rs b/crate/rt/src/cmds/clean_cmd.rs index 451c73cab..df42be203 100644 --- a/crate/rt/src/cmds/clean_cmd.rs +++ b/crate/rt/src/cmds/clean_cmd.rs @@ -63,7 +63,7 @@ where pub async fn exec_dry<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -82,7 +82,7 @@ where cmd_ctx: &mut CmdCtx>, apply_stored_state_sync: ApplyStoredStateSync, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -97,7 +97,7 @@ where cmd_ctx .view() .resources - .insert::>(states_previous); + .insert::(states_previous); states_cleaned } @@ -182,7 +182,7 @@ where let (states_previous, states_cleaned) = *states_previous_and_cleaned; Self::serialize_current(item_graph, resources, &states_cleaned).await?; - resources.insert::>(states_previous); + resources.insert::(states_previous); Ok(states_cleaned) } @@ -250,8 +250,8 @@ where }, )) .with_execution_outcome_fetch(|resources| { - let states_previous = resources.try_remove::>(); - let states_cleaned = resources.try_remove::>(); + let states_previous = resources.try_remove::(); + let states_cleaned = resources.try_remove::>(); states_previous.ok().zip(states_cleaned.ok()).map( |(states_previous, states_cleaned)| { @@ -315,5 +315,5 @@ enum CleanExecChange { /// /// This variant is used for both partial and complete execution, as long as /// some state was altered. - Some(Box<(StatesPrevious, States)>), + Some(Box<(StatesPrevious, States)>), } diff --git a/crate/rt/src/cmds/ensure_cmd.rs b/crate/rt/src/cmds/ensure_cmd.rs index 69e3783c4..213612f02 100644 --- a/crate/rt/src/cmds/ensure_cmd.rs +++ b/crate/rt/src/cmds/ensure_cmd.rs @@ -55,7 +55,7 @@ where pub async fn exec_dry<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -74,7 +74,7 @@ where cmd_ctx: &mut CmdCtx>, apply_stored_state_sync: ApplyStoredStateSync, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -89,7 +89,7 @@ where cmd_ctx .view() .resources - .insert::>(states_previous); + .insert::(states_previous); states_applied_dry } @@ -124,7 +124,7 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -143,7 +143,7 @@ where cmd_ctx: &mut CmdCtx>, apply_stored_state_sync: ApplyStoredStateSync, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -167,7 +167,7 @@ where Self::serialize_current(item_graph, resources, &states_applied).await?; Self::serialize_goal(item_graph, resources, &states_goal).await?; - resources.insert::>(states_previous); + resources.insert::(states_previous); Ok(states_applied) } @@ -181,7 +181,7 @@ where /// Conditionally runs [`ApplyFns`]`::`[`exec`] for each [`Item`]. /// /// Same as [`Self::exec`], but does not change the type state, and returns - /// [`StatesEnsured`]. + /// [`StatesEnsured`]. /// /// [`exec`]: peace_cfg::ApplyFns::exec /// [`Item`]: peace_cfg::Item @@ -241,9 +241,9 @@ where .with_cmd_block(CmdBlockWrapper::new( ApplyExecCmdBlock::::new(), |(states_previous, states_applied, states_target): ( - StatesPrevious, - States, - States, + StatesPrevious, + States, + States, )| { EnsureExecChange::Some(Box::new(( states_previous, @@ -253,9 +253,9 @@ where }, )) .with_execution_outcome_fetch(|resources| { - let states_previous = resources.try_remove::>(); - let states_applied = resources.try_remove::>(); - let states_goal = resources.try_remove::>(); + let states_previous = resources.try_remove::(); + let states_applied = resources.try_remove::>(); + let states_goal = resources.try_remove::(); if let Some(((states_previous, states_applied), states_goal)) = states_previous .ok() @@ -294,7 +294,7 @@ where async fn serialize_current( item_graph: &ItemGraph<::AppError>, resources: &Resources, - states_applied: &StatesEnsured, + states_applied: &StatesEnsured, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; @@ -314,7 +314,7 @@ where async fn serialize_goal( item_graph: &ItemGraph<::AppError>, resources: &Resources, - states_goal: &StatesGoal, + states_goal: &StatesGoal, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; @@ -345,11 +345,5 @@ enum EnsureExecChange { /// /// This variant is used for both partial and complete execution, as long as /// some state was altered. - Some( - Box<( - StatesPrevious, - States, - StatesGoal, - )>, - ), + Some(Box<(StatesPrevious, States, StatesGoal)>), } diff --git a/crate/rt/src/cmds/states_current_read_cmd.rs b/crate/rt/src/cmds/states_current_read_cmd.rs index e01fbde92..7768dec8b 100644 --- a/crate/rt/src/cmds/states_current_read_cmd.rs +++ b/crate/rt/src/cmds/states_current_read_cmd.rs @@ -10,7 +10,7 @@ use peace_resources::states::StatesCurrentStored; use crate::cmd_blocks::StatesCurrentReadCmdBlock; -/// Reads [`StatesCurrentStored`]s from storage. +/// Reads [`StatesCurrentStored`]s from storage. #[derive(Debug)] pub struct StatesCurrentReadCmd(PhantomData); @@ -18,30 +18,27 @@ impl StatesCurrentReadCmd where CmdCtxTypesT: CmdCtxTypesConstrained, { - /// Reads [`StatesCurrentStored`]s from storage. + /// Reads [`StatesCurrentStored`]s from storage. /// - /// Either [`StatesCurrentStoredDiscoverCmd`] or - /// [`StatesDiscoverCmd`] must have run prior to this command to read - /// the state. + /// Either [`StatesCurrentStoredDiscoverCmd`] or [`StatesDiscoverCmd`] must + /// have run prior to this command to read the state. /// - /// [`StatesCurrentStoredDiscoverCmd`]: crate::StatesCurrentStoredDiscoverCmd + /// [`StatesCurrentStoredDiscoverCmd`]: crate::StatesCurrentStoredDiscoverCmd /// [`StatesDiscoverCmd`]: crate::StatesDiscoverCmd pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome< - StatesCurrentStored, - ::AppError, - >, + CmdOutcome::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let cmd_execution_builder = - CmdExecution::, _>::builder().with_cmd_block( - CmdBlockWrapper::new(StatesCurrentReadCmdBlock::new(), std::convert::identity), - ); + let cmd_execution_builder = CmdExecution::::builder() + .with_cmd_block(CmdBlockWrapper::new( + StatesCurrentReadCmdBlock::new(), + std::convert::identity, + )); #[cfg(feature = "output_progress")] let cmd_execution_builder = cmd_execution_builder.with_progress_render_enabled(false); diff --git a/crate/rt/src/cmds/states_current_stored_display_cmd.rs b/crate/rt/src/cmds/states_current_stored_display_cmd.rs index 90ef0934f..4757ab742 100644 --- a/crate/rt/src/cmds/states_current_stored_display_cmd.rs +++ b/crate/rt/src/cmds/states_current_stored_display_cmd.rs @@ -18,7 +18,7 @@ impl StatesCurrentStoredDisplayCmd where CmdCtxTypesT: CmdCtxTypesConstrained, { - /// Displays [`StatesCurrentStored`]s from storage. + /// Displays [`StatesCurrentStored`]s from storage. /// /// [`StatesDiscoverCmd`] must have run prior to this command to read the /// state. @@ -27,10 +27,7 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome< - StatesCurrentStored, - ::AppError, - >, + CmdOutcome::AppError>, ::AppError, > where diff --git a/crate/rt/src/cmds/states_discover_cmd.rs b/crate/rt/src/cmds/states_discover_cmd.rs index 32ce0b3f9..a437d9f6f 100644 --- a/crate/rt/src/cmds/states_discover_cmd.rs +++ b/crate/rt/src/cmds/states_discover_cmd.rs @@ -49,7 +49,7 @@ where pub async fn current<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -76,13 +76,13 @@ where cmd_ctx: &mut CmdCtx>, serialize_to_storage: bool, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let mut cmd_execution = CmdExecution::, _>::builder() + let mut cmd_execution = CmdExecution::::builder() .with_cmd_block(CmdBlockWrapper::new( #[cfg(not(feature = "output_progress"))] StatesDiscoverCmdBlock::current(), @@ -129,7 +129,7 @@ where pub async fn goal<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where @@ -156,13 +156,13 @@ where cmd_ctx: &mut CmdCtx>, serialize_to_storage: bool, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let mut cmd_execution = CmdExecution::, _>::builder() + let mut cmd_execution = CmdExecution::::builder() .with_cmd_block(CmdBlockWrapper::new( #[cfg(not(feature = "output_progress"))] StatesDiscoverCmdBlock::goal(), @@ -218,10 +218,7 @@ where pub async fn current_and_goal<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome< - (StatesCurrent, StatesGoal), - ::AppError, - >, + CmdOutcome<(StatesCurrent, StatesGoal), ::AppError>, ::AppError, > where @@ -250,38 +247,34 @@ where cmd_ctx: &mut CmdCtx>, serialize_to_storage: bool, ) -> Result< - CmdOutcome< - (StatesCurrent, StatesGoal), - ::AppError, - >, + CmdOutcome<(StatesCurrent, StatesGoal), ::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let mut cmd_execution = - CmdExecution::<(StatesCurrent, StatesGoal), _>::builder() - .with_cmd_block(CmdBlockWrapper::new( - #[cfg(not(feature = "output_progress"))] - StatesDiscoverCmdBlock::current_and_goal(), - #[cfg(feature = "output_progress")] - StatesDiscoverCmdBlock::current_and_goal().progress_complete_on_success(), - |states_current_and_goal_mut| { - let (states_current_mut, states_goal_mut) = states_current_and_goal_mut; - - ( - StatesCurrent::from(states_current_mut), - StatesGoal::from(states_goal_mut), - ) - }, - )) - .with_execution_outcome_fetch(|resources| { - let states_current = resources.try_remove::>(); - let states_goal = resources.try_remove::>(); - - states_current.ok().zip(states_goal.ok()) - }) - .build(); + let mut cmd_execution = CmdExecution::<(StatesCurrent, StatesGoal), _>::builder() + .with_cmd_block(CmdBlockWrapper::new( + #[cfg(not(feature = "output_progress"))] + StatesDiscoverCmdBlock::current_and_goal(), + #[cfg(feature = "output_progress")] + StatesDiscoverCmdBlock::current_and_goal().progress_complete_on_success(), + |states_current_and_goal_mut| { + let (states_current_mut, states_goal_mut) = states_current_and_goal_mut; + + ( + StatesCurrent::from(states_current_mut), + StatesGoal::from(states_goal_mut), + ) + }, + )) + .with_execution_outcome_fetch(|resources| { + let states_current = resources.try_remove::(); + let states_goal = resources.try_remove::(); + + states_current.ok().zip(states_goal.ok()) + }) + .build(); let cmd_outcome = cmd_execution.exec(cmd_ctx).await?; @@ -304,7 +297,7 @@ where async fn serialize_current( item_graph: &ItemGraph<::AppError>, resources: &mut Resources, - states_current: &StatesCurrent, + states_current: &StatesCurrent, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; @@ -326,7 +319,7 @@ where async fn serialize_goal( item_graph: &ItemGraph<::AppError>, resources: &mut Resources, - states_goal: &StatesGoal, + states_goal: &StatesGoal, ) -> Result<(), ::AppError> { use peace_rt_model::StatesSerializer; diff --git a/crate/rt/src/cmds/states_goal_display_cmd.rs b/crate/rt/src/cmds/states_goal_display_cmd.rs index 0eda48023..9388d2493 100644 --- a/crate/rt/src/cmds/states_goal_display_cmd.rs +++ b/crate/rt/src/cmds/states_goal_display_cmd.rs @@ -28,7 +28,7 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where diff --git a/crate/rt/src/cmds/states_goal_read_cmd.rs b/crate/rt/src/cmds/states_goal_read_cmd.rs index 33776ed65..30315d534 100644 --- a/crate/rt/src/cmds/states_goal_read_cmd.rs +++ b/crate/rt/src/cmds/states_goal_read_cmd.rs @@ -10,7 +10,7 @@ use peace_resources::states::StatesGoalStored; use crate::cmd_blocks::StatesGoalReadCmdBlock; -/// Reads [`StatesGoalStored`]s from storage. +/// Reads [`StatesGoalStored`]s from storage. #[derive(Debug)] pub struct StatesGoalReadCmd(PhantomData); @@ -18,7 +18,7 @@ impl StatesGoalReadCmd where CmdCtxTypesT: CmdCtxTypesConstrained, { - /// Reads [`StatesGoalStored`]s from storage. + /// Reads [`StatesGoalStored`]s from storage. /// /// [`StatesDiscoverCmd`] must have run prior to this command to read the /// state. @@ -27,16 +27,15 @@ where pub async fn exec<'ctx>( cmd_ctx: &mut CmdCtx>, ) -> Result< - CmdOutcome, ::AppError>, + CmdOutcome::AppError>, ::AppError, > where CmdCtxTypesT: 'ctx, { - let cmd_execution_builder = - CmdExecution::, _>::builder().with_cmd_block( - CmdBlockWrapper::new(StatesGoalReadCmdBlock::new(), std::convert::identity), - ); + let cmd_execution_builder = CmdExecution::::builder().with_cmd_block( + CmdBlockWrapper::new(StatesGoalReadCmdBlock::new(), std::convert::identity), + ); #[cfg(feature = "output_progress")] let cmd_execution_builder = cmd_execution_builder.with_progress_render_enabled(false); diff --git a/crate/rt_model/src/item_graph.rs b/crate/rt_model/src/item_graph.rs index f0429a6e1..3af8c64de 100644 --- a/crate/rt_model/src/item_graph.rs +++ b/crate/rt_model/src/item_graph.rs @@ -43,10 +43,7 @@ impl ItemGraph { /// /// This will contain an entry for all items, in order of flow item /// insertion, whether or not a state exists in the provided `states` map. - pub fn states_serde( - &self, - states: &States, - ) -> StatesSerde + pub fn states_serde(&self, states: &States) -> StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, E: 'static, @@ -78,7 +75,7 @@ impl From>> for ItemGraph { } } -impl<'graph, ValueT, E> From<&'graph ItemGraph> for StatesSerde +impl<'graph, ValueT, E> From<&'graph ItemGraph> for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, E: 'static, diff --git a/crate/rt_model/src/item_rt.rs b/crate/rt_model/src/item_rt.rs index 80222dd85..294d29d33 100644 --- a/crate/rt_model/src/item_rt.rs +++ b/crate/rt_model/src/item_rt.rs @@ -199,7 +199,7 @@ pub trait ItemRt: /// [`ApplyFns::check`]: peace_cfg::Item::ApplyFns async fn clean_prepare( &self, - states_current: &StatesCurrent, + states_current: &StatesCurrent, params_specs: &ParamsSpecs, resources: &Resources, ) -> Result diff --git a/crate/rt_model/src/item_wrapper.rs b/crate/rt_model/src/item_wrapper.rs index 82b8cd0bb..d623e1a7b 100644 --- a/crate/rt_model/src/item_wrapper.rs +++ b/crate/rt_model/src/item_wrapper.rs @@ -82,14 +82,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Clean, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); I::state_clean(¶ms_partial, data).await? @@ -113,14 +113,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); I::try_state_current(fn_ctx, ¶ms_partial, data).await? @@ -146,14 +146,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); I::state_current(fn_ctx, ¶ms, data).await? @@ -176,14 +176,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Goal, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); let state_goal = I::try_state_goal(fn_ctx, ¶ms_partial, data).await?; @@ -223,14 +223,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( value_resolution_mode, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); let state_goal = I::state_goal(fn_ctx, ¶ms, data).await?; @@ -297,14 +297,14 @@ where // // Running `diff` for multiple profiles will likely be between two profiles' // current states. - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Goal, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); I::state_diff(¶ms_partial, data, state_a, state_b) @@ -339,14 +339,14 @@ where // parameters to be used. Note that during an apply, the goal state is // resolved as execution happens -- values that rely on predecessors' applied // state will be fed into successors' goal state. - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( value_resolution_mode, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve_partial(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); if let Ok(params) = params_partial.try_into() { @@ -379,14 +379,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); let state_ensured_dry = @@ -415,14 +415,14 @@ where .ok_or_else(|| crate::Error::ParamsSpecNotFound { item_id: item_id.clone(), })?; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id.clone(), tynm::type_name::>(), ); params_spec .resolve(resources, &mut value_resolution_ctx) - .map_err(crate::Error::ParamsResolveError::)? + .map_err(crate::Error::ParamsResolveError)? }; let data = as Data>::borrow(self.id(), resources); let state_ensured = I::apply(fn_ctx, ¶ms, data, state_current, state_goal, state_diff) @@ -832,7 +832,7 @@ where async fn clean_prepare( &self, - states_current: &StatesCurrent, + states_current: &StatesCurrent, params_specs: &ParamsSpecs, resources: &Resources, ) -> Result { diff --git a/crate/rt_model/src/states_serializer.rs b/crate/rt_model/src/states_serializer.rs index bcc765819..b4e03a6cf 100644 --- a/crate/rt_model/src/states_serializer.rs +++ b/crate/rt_model/src/states_serializer.rs @@ -12,16 +12,16 @@ use peace_resources::{ use crate::{Error, ItemGraph, Storage}; -/// Reads and writes [`StatesCurrentStored`] and -/// [`StatesGoalStored`] to and from storage. +/// Reads and writes [`StatesCurrentStored`] and [`StatesGoalStored`] to and +/// from storage. pub struct StatesSerializer(PhantomData); impl StatesSerializer where E: std::error::Error + From + Send + 'static, { - /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it - /// exists on disk. + /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it exists on + /// disk. /// /// # Parameters: /// @@ -30,10 +30,10 @@ where /// * `states_file_path`: Path to save the serialized states to. /// /// [`Item`]: peace_cfg::Item - pub async fn serialize( + pub async fn serialize( storage: &Storage, item_graph: &ItemGraph, - states: &States, + states: &States, states_file_path: &Path, ) -> Result<(), E> where @@ -53,8 +53,8 @@ where Ok(()) } - /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it - /// exists on disk. + /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it exists on + /// disk. /// /// # Parameters: /// @@ -69,7 +69,7 @@ where storage: &Storage, states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, - ) -> Result, E> { + ) -> Result { let states = Self::deserialize_internal::( #[cfg(not(target_arch = "wasm32"))] "StatesSerializer::deserialize_stored".to_string(), @@ -83,8 +83,7 @@ where states.ok_or_else(|| E::from(Error::StatesCurrentDiscoverRequired)) } - /// Returns the [`StatesGoalStored`] of all [`Item`]s if it exists - /// on disk. + /// Returns the [`StatesGoalStored`] of all [`Item`]s if it exists on disk. /// /// # Parameters: /// @@ -99,7 +98,7 @@ where storage: &Storage, states_type_reg: &TypeReg, states_goal_file: &StatesGoalFile, - ) -> Result, E> { + ) -> Result { let states = Self::deserialize_internal::( #[cfg(not(target_arch = "wasm32"))] "StatesSerializer::deserialize_goal".to_string(), @@ -113,8 +112,8 @@ where states.ok_or_else(|| E::from(Error::StatesGoalDiscoverRequired)) } - /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it - /// exists on disk. + /// Returns the [`StatesCurrentStored`] of all [`Item`]s if it exists on + /// disk. /// /// # Parameters: /// @@ -129,7 +128,7 @@ where storage: &Storage, states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, - ) -> Result>, E> { + ) -> Result, E> { Self::deserialize_internal( #[cfg(not(target_arch = "wasm32"))] "StatesSerializer::deserialize_stored_opt".to_string(), @@ -159,13 +158,13 @@ where /// [`ts::Current`]: peace_resources::states::ts::Current /// [`ts::CurrentStored`]: peace_resources::states::ts::CurrentStored #[cfg(not(target_arch = "wasm32"))] - async fn deserialize_internal( + async fn deserialize_internal( thread_name: String, flow_id: &FlowId, storage: &Storage, states_type_reg: &TypeReg, states_file_path: &Path, - ) -> Result>, E> + ) -> Result>, E> where TS: Send + Sync, { @@ -227,12 +226,12 @@ where /// [`ts::Current`]: peace_resources::states::ts::Current /// [`ts::CurrentStored`]: peace_resources::states::ts::CurrentStored #[cfg(target_arch = "wasm32")] - async fn deserialize_internal( + async fn deserialize_internal( flow_id: &FlowId, storage: &Storage, states_type_reg: &TypeReg, states_file_path: &Path, - ) -> Result>, E> + ) -> Result>, E> where TS: Send + Sync, { diff --git a/workspace_tests/src/cfg/stored.rs b/workspace_tests/src/cfg/stored.rs index c968e50fb..44d063d08 100644 --- a/workspace_tests/src/cfg/stored.rs +++ b/workspace_tests/src/cfg/stored.rs @@ -16,7 +16,7 @@ fn retrieves_state_for_item() { let mut states_mut = StatesMut::new(); states_mut.insert(ITEM_SPEC_ID_TEST.clone(), 123u8); - StatesCurrentStored::::from(states_mut) + StatesCurrentStored::from(states_mut) }; resources.insert(states_current_stored); @@ -32,7 +32,7 @@ fn does_not_retrieve_state_for_item_other() { let mut states_mut = StatesMut::new(); states_mut.insert(ITEM_SPEC_ID_OTHER.clone(), 123u8); - StatesCurrentStored::::from(states_mut) + StatesCurrentStored::from(states_mut) }; resources.insert(states_current_stored); @@ -44,7 +44,7 @@ fn does_not_retrieve_state_for_item_other() { #[test] fn data_access_borrows_returns_states_current_stored_type_id() { let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::>()); + type_ids.push(TypeId::of::()); assert_eq!(type_ids, as DataAccess>::borrows()); } @@ -59,12 +59,12 @@ fn data_access_borrow_muts_is_empty() { #[test] fn data_access_dyn_borrows_returns_states_current_stored_type_id() { let mut resources = Resources::new(); - let states_current_stored = StatesCurrentStored::::from(StatesMut::new()); + let states_current_stored = StatesCurrentStored::from(StatesMut::new()); resources.insert(states_current_stored); let stored = Stored::<'_, u8>::borrow(ITEM_SPEC_ID_TEST, &resources); let mut type_ids = TypeIds::new(); - type_ids.push(TypeId::of::>()); + type_ids.push(TypeId::of::()); assert_eq!( type_ids, @@ -75,7 +75,7 @@ fn data_access_dyn_borrows_returns_states_current_stored_type_id() { #[test] fn data_access_dyn_borrow_muts_is_empty() { let mut resources = Resources::new(); - let states_current_stored = StatesCurrentStored::::from(StatesMut::new()); + let states_current_stored = StatesCurrentStored::from(StatesMut::new()); resources.insert(states_current_stored); let stored = Stored::<'_, u8>::borrow(ITEM_SPEC_ID_TEST, &resources); @@ -94,7 +94,7 @@ fn debug() { let mut states_mut = StatesMut::new(); states_mut.insert(ITEM_SPEC_ID_TEST.clone(), 123u8); - StatesCurrentStored::::from(states_mut) + StatesCurrentStored::from(states_mut) }; resources.insert(states_current_stored); diff --git a/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs b/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs index 31d2eb448..e9b26e461 100644 --- a/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs +++ b/workspace_tests/src/cmd/ctx/cmd_ctx_builder/single_profile_single_flow_builder.rs @@ -418,7 +418,7 @@ async fn build_with_item_params_returns_ok_when_params_provided() let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -518,7 +518,7 @@ async fn build_with_item_params_returns_ok_when_params_not_provided_but_are_stor let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -571,7 +571,7 @@ async fn build_with_item_params_returns_ok_and_uses_params_provided_when_params_ let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -779,7 +779,7 @@ async fn build_with_item_params_returns_ok_when_spec_provided_for_previous_mappi let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), @@ -1066,7 +1066,7 @@ async fn build_with_item_params_returns_ok_when_new_item_added_with_params_provi let resources = scope.resources(); let vec_a_spec = params_specs .get::::Params<'_>>, _>(VecCopyItem::ID_DEFAULT); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, VecCopyItem::ID_DEFAULT.clone(), tynm::type_name::(), diff --git a/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs b/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs index 5eeadfee7..123ad3114 100644 --- a/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs +++ b/workspace_tests/src/cmd_rt/cmd_execution/cmd_execution_error_builder.rs @@ -69,9 +69,9 @@ async fn builds_error_for_missing_input_tuple_first_parameter() -> Result<(), Pe })) => { assert_eq!(2, cmd_block_descs.len()); assert_eq!(1, cmd_block_index); - assert_eq!("States", input_name_short); + assert_eq!("States", input_name_short); assert_eq!( - "peace_resources::states::States", + "peace_resources::states::States", input_name_full ); #[cfg(feature = "error_reporting")] @@ -82,17 +82,17 @@ async fn builds_error_for_missing_input_tuple_first_parameter() -> Result<(), Pe CmdBlocks: - StatesDiscoverCmdBlock: Input: () - Outcome: States + Outcome: States - DiffCmdBlock: - Input: (States, States) - Outcome: (StateDiffs, States, States) + Input: (States, States) + Outcome: (StateDiffs, States, States) "#, cmd_execution_src ); match input_span { Some(input_span) => { assert_eq!(154, input_span.offset()); - assert_eq!("States".len(), input_span.len()); + assert_eq!("States".len(), input_span.len()); } None => panic!( "Expected `input_span` to be `Some(SourceSpan::from((154, 15)))`, but was `None`." @@ -158,9 +158,9 @@ async fn builds_error_for_missing_input_tuple_second_parameter() -> Result<(), P })) => { assert_eq!(2, cmd_block_descs.len()); assert_eq!(1, cmd_block_index); - assert_eq!("States", input_name_short); + assert_eq!("States", input_name_short); assert_eq!( - "peace_resources::states::States", + "peace_resources::states::States", input_name_full ); #[cfg(feature = "error_reporting")] @@ -171,17 +171,17 @@ async fn builds_error_for_missing_input_tuple_second_parameter() -> Result<(), P CmdBlocks: - StatesDiscoverCmdBlock: Input: () - Outcome: States + Outcome: States - DiffCmdBlock: - Input: (States, States) - Outcome: (StateDiffs, States, States) + Input: (States, States) + Outcome: (StateDiffs, States, States) "#, cmd_execution_src ); match input_span { Some(input_span) => { assert_eq!(174, input_span.offset()); - assert_eq!("States".len(), input_span.len()); + assert_eq!("States".len(), input_span.len()); } None => panic!( "Expected `input_span` to be `Some(SourceSpan::from((174, 12)))`, but was `None`." diff --git a/workspace_tests/src/items/tar_x_item.rs b/workspace_tests/src/items/tar_x_item.rs index 9ce28f595..fa83a1582 100644 --- a/workspace_tests/src/items/tar_x_item.rs +++ b/workspace_tests/src/items/tar_x_item.rs @@ -572,7 +572,7 @@ async fn ensure_check_returns_exec_not_required_when_tar_and_dest_in_sync() let tar_x_params_spec = params_specs .get::>, _>(TarXTest::ID) .unwrap(); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, TarXTest::ID.clone(), tynm::type_name::>(), diff --git a/workspace_tests/src/mock_item.rs b/workspace_tests/src/mock_item.rs index 8851b5e75..3d2967d97 100644 --- a/workspace_tests/src/mock_item.rs +++ b/workspace_tests/src/mock_item.rs @@ -350,10 +350,8 @@ where resources.insert(self.mock_fns.clone()); let mock_dest = { - let states_current_stored = > as Data>::borrow( - Self::ID_DEFAULT, - resources, - ); + let states_current_stored = + as Data>::borrow(Self::ID_DEFAULT, resources); let mock_state_current_stored: Option<&'_ MockState> = states_current_stored .as_ref() .and_then(|states_current_stored| states_current_stored.get(self.id())); diff --git a/workspace_tests/src/params/derive.rs b/workspace_tests/src/params/derive.rs index 8dd941ecc..830f1efc4 100644 --- a/workspace_tests/src/params/derive.rs +++ b/workspace_tests/src/params/derive.rs @@ -134,7 +134,7 @@ mod struct_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("StructParams"), @@ -345,7 +345,7 @@ mod struct_with_type_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("StructWithTypeParams<()>"), @@ -547,7 +547,7 @@ mod tuple_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("TupleParams"), @@ -727,7 +727,7 @@ mod tuple_with_type_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("TupleWithTypeParams<()>"), @@ -1011,7 +1011,7 @@ mod enum_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_named_from_field_wise_builder"), String::from("EnumParams<()>"), @@ -1046,7 +1046,7 @@ mod enum_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_tuple_from_field_wise_builder"), String::from("EnumParams<()>"), @@ -1080,7 +1080,7 @@ mod enum_params { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_tuple_marker_from_field_wise_builder"), String::from("EnumParams<()>"), @@ -1585,7 +1585,7 @@ mod struct_recursive_value { resources.insert(1u32); Resources::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("field_wise_from_field_wise_builder"), String::from("StructRecursiveValue<()>"), diff --git a/workspace_tests/src/params/mapping_fn_impl.rs b/workspace_tests/src/params/mapping_fn_impl.rs index 504ebcce8..ad7df3c0e 100644 --- a/workspace_tests/src/params/mapping_fn_impl.rs +++ b/workspace_tests/src/params/mapping_fn_impl.rs @@ -43,7 +43,7 @@ macro_rules! mapping_tests { data::marker::$value_resolution_mode, cfg::{item_id}, params::{ - MappingFn, MappingFnImpl, ParamsResolveError, + MappingFn, MappingFnImpl, ParamsResolveError, ValueResolutionCtx, ValueResolutionMode, }, resources::{resources::ts::SetUp, Resources}, @@ -51,7 +51,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_ok_when_referenced_values_are_present_directly() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -64,7 +64,7 @@ macro_rules! mapping_tests { resources.insert(2u64); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -82,7 +82,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_ok_when_referenced_values_are_present_through_data_marker() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -95,7 +95,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -113,7 +113,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_err_when_referenced_value_is_none() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -126,7 +126,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(None::)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -143,7 +143,7 @@ macro_rules! mapping_tests { assert!( matches!( &sum_result, - Err(ParamsResolveError::::FromMap { + Err(ParamsResolveError::FromMap { value_resolution_ctx, from_type_name }) @@ -160,7 +160,7 @@ macro_rules! mapping_tests { && from_type_name == "u64" // u64 is missing from `resources` ), "expected `sum_result` to be \ - `Err(ParamsResolveError::::FromMap {{ .. }}`,\n\ + `Err(ParamsResolveError::FromMap {{ .. }}`,\n\ but was {sum_result:?}" ); } @@ -171,7 +171,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_map_returns_err_when_referenced_value_is_absent() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -184,7 +184,7 @@ macro_rules! mapping_tests { // resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -202,7 +202,7 @@ macro_rules! mapping_tests { assert!( matches!( &sum_result, - Err(ParamsResolveError::::FromMap { + Err(ParamsResolveError::FromMap { value_resolution_ctx, from_type_name }) @@ -219,7 +219,7 @@ macro_rules! mapping_tests { && from_type_name == "u64" // u64 is missing from `resources` ), "expected `sum_result` to be \ - `Err(ParamsResolveError::::FromMap {{ .. }}`,\n\ + `Err(ParamsResolveError::FromMap {{ .. }}`,\n\ but was {sum_result:?}" ); } @@ -230,7 +230,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_try_map_returns_ok_some_when_referenced_values_are_present() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -243,7 +243,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -261,7 +261,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_try_map_returns_ok_none_when_referenced_value_is_none() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -274,7 +274,7 @@ macro_rules! mapping_tests { resources.insert($value_resolution_mode(None::)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), @@ -292,7 +292,7 @@ macro_rules! mapping_tests { #[test] fn mapping_fn_try_map_returns_ok_none_when_referenced_value_is_absent() - -> Result<(), ParamsResolveError> { + -> Result<(), ParamsResolveError> { let mapping_fn_impl = MappingFnImpl::from((Some(String::from("field_name")), |a: &u32, b: &u64| { let a = u16::try_from(*a).ok()?; @@ -305,7 +305,7 @@ macro_rules! mapping_tests { // resources.insert($value_resolution_mode(Some(2u64))); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::$value_resolution_mode, item_id!("mapping_fn_map"), String::from(crate::fn_name_short!()), diff --git a/workspace_tests/src/params/params_spec.rs b/workspace_tests/src/params/params_spec.rs index 06b758d16..814632c5d 100644 --- a/workspace_tests/src/params/params_spec.rs +++ b/workspace_tests/src/params/params_spec.rs @@ -240,7 +240,7 @@ marker: null #[test] fn deserialize_field_wise_value() -> Result<(), Box> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::ApplyDry, item_id!("deserialize_field_wise"), tynm::type_name::(), @@ -402,13 +402,13 @@ field_wise_spec: !MappingFn } #[test] -fn resolve_stored_param() -> Result<(), ParamsResolveError> { +fn resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_stored_param"), tynm::type_name::(), @@ -422,13 +422,13 @@ fn resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory() -> Result<(), ParamsResolveError> { +fn resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory"), tynm::type_name::(), @@ -442,9 +442,9 @@ fn resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_not_found"), tynm::type_name::(), @@ -460,14 +460,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemory { value_resolution_ctx }) + Err(ParamsResolveError::InMemory { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_not_found") && value_resolution_ctx.params_type_name() == "MockSrc" && value_resolution_ctx.resolution_chain().is_empty() ), - "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ + "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ but was `{mock_src_result:?}`" ); } @@ -476,14 +476,13 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr } #[test] -fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -500,7 +499,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_mutably_borrowed") @@ -508,7 +507,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -518,9 +517,9 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes } #[test] -fn resolve_value() -> Result<(), ParamsResolveError> { +fn resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_value"), tynm::type_name::(), @@ -534,13 +533,13 @@ fn resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn"), tynm::type_name::(), @@ -554,15 +553,14 @@ fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -580,7 +578,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -589,7 +587,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -599,13 +597,13 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn resolve_field_wise() -> Result<(), ParamsResolveError> { +fn resolve_field_wise() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_field_wise"), tynm::type_name::(), @@ -619,14 +617,13 @@ fn resolve_field_wise() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_field_wise_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -643,7 +640,7 @@ fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_field_wise_returns_err_when_mutably_borrowed") @@ -653,7 +650,7 @@ fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe ] ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[(0, u8)]`,\n\ but was `{mock_src_result:?}`" ); @@ -663,13 +660,13 @@ fn resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { +fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_stored_param"), tynm::type_name::(), @@ -683,13 +680,13 @@ fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory"), tynm::type_name::(), @@ -703,9 +700,9 @@ fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_none_when_not_found"), tynm::type_name::(), @@ -719,14 +716,13 @@ fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResol } #[test] -fn try_resolve_in_memory_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -743,7 +739,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed") @@ -751,7 +747,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -761,9 +757,9 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() } #[test] -fn try_resolve_value() -> Result<(), ParamsResolveError> { +fn try_resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_value"), tynm::type_name::(), @@ -777,13 +773,13 @@ fn try_resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn"), tynm::type_name::(), @@ -797,15 +793,14 @@ fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -823,7 +818,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -832,7 +827,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -842,13 +837,13 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() } #[test] -fn try_resolve_field_wise() -> Result<(), ParamsResolveError> { +fn try_resolve_field_wise() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_field_wise"), tynm::type_name::(), @@ -862,14 +857,13 @@ fn try_resolve_field_wise() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_field_wise_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_field_wise_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_field_wise_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -886,7 +880,7 @@ fn try_resolve_field_wise_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_field_wise_returns_err_when_mutably_borrowed") @@ -896,7 +890,7 @@ fn try_resolve_field_wise_returns_err_when_mutably_borrowed() ] ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[(0, u8)]`,\n\ but was `{mock_src_result:?}`" ); diff --git a/workspace_tests/src/params/params_spec_fieldless.rs b/workspace_tests/src/params/params_spec_fieldless.rs index 905b711e8..7d0cc66f5 100644 --- a/workspace_tests/src/params/params_spec_fieldless.rs +++ b/workspace_tests/src/params/params_spec_fieldless.rs @@ -208,13 +208,13 @@ marker: null } #[test] -fn resolve_stored_param() -> Result<(), ParamsResolveError> { +fn resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_stored_param"), tynm::type_name::(), @@ -228,13 +228,13 @@ fn resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory() -> Result<(), ParamsResolveError> { +fn resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory"), tynm::type_name::(), @@ -248,9 +248,9 @@ fn resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_not_found"), tynm::type_name::(), @@ -266,14 +266,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemory { value_resolution_ctx }) + Err(ParamsResolveError::InMemory { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_not_found") && value_resolution_ctx.params_type_name() == "MockSrc" && value_resolution_ctx.resolution_chain().is_empty() ), - "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ + "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ but was `{mock_src_result:?}`" ); } @@ -282,14 +282,13 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr } #[test] -fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -306,7 +305,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_mutably_borrowed") @@ -314,7 +313,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -324,9 +323,9 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes } #[test] -fn resolve_value() -> Result<(), ParamsResolveError> { +fn resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_value"), tynm::type_name::(), @@ -340,13 +339,13 @@ fn resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn"), tynm::type_name::(), @@ -360,15 +359,14 @@ fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -387,7 +385,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -396,7 +394,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -406,13 +404,13 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { +fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_stored_param"), tynm::type_name::(), @@ -426,13 +424,13 @@ fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory"), tynm::type_name::(), @@ -446,9 +444,9 @@ fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_none_when_not_found"), tynm::type_name::(), @@ -462,14 +460,13 @@ fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResol } #[test] -fn try_resolve_in_memory_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -486,7 +483,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed") @@ -494,7 +491,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -504,9 +501,9 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() } #[test] -fn try_resolve_value() -> Result<(), ParamsResolveError> { +fn try_resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_value"), tynm::type_name::(), @@ -520,13 +517,13 @@ fn try_resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn"), tynm::type_name::(), @@ -540,15 +537,14 @@ fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -567,7 +563,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -576,7 +572,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); diff --git a/workspace_tests/src/params/value_resolution_ctx.rs b/workspace_tests/src/params/value_resolution_ctx.rs index 864f42897..73719c271 100644 --- a/workspace_tests/src/params/value_resolution_ctx.rs +++ b/workspace_tests/src/params/value_resolution_ctx.rs @@ -1,20 +1,20 @@ use peace::{ cfg::item_id, - params::{FieldNameAndType, ValueResolutionCtx, ValueResolutionMode}, + params::{FieldNameAndType, ValueResolutionCtx, ValueResolutionMode}, }; use crate::mock_item::MockSrc; #[test] fn debug() { - let value_resolution_ctx = ValueResolutionCtx::::new( + let value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("item_id"), tynm::type_name::(), ); assert_eq!( - "ValueResolutionCtx { \ + "ValueResolutionCtx { \ value_resolution_mode: Current, \ item_id: ItemId(\"item_id\"), \ params_type_name: \"MockSrc\", \ @@ -26,13 +26,13 @@ fn debug() { #[test] fn partial_eq() { - let value_resolution_ctx_0 = ValueResolutionCtx::::new( + let value_resolution_ctx_0 = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("item_id_0"), tynm::type_name::(), ); - let value_resolution_ctx_1 = ValueResolutionCtx::::new( + let value_resolution_ctx_1 = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("item_id_1"), tynm::type_name::(), @@ -44,7 +44,7 @@ fn partial_eq() { #[test] fn display_no_resolution_chain() { - let value_resolution_ctx = ValueResolutionCtx::::new( + let value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("item_id"), tynm::type_name::(), @@ -55,7 +55,7 @@ fn display_no_resolution_chain() { #[test] fn display_with_resolution_chain() { - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("item_id"), tynm::type_name::(), diff --git a/workspace_tests/src/params/value_spec.rs b/workspace_tests/src/params/value_spec.rs index 962dc0a9a..e73cfa04b 100644 --- a/workspace_tests/src/params/value_spec.rs +++ b/workspace_tests/src/params/value_spec.rs @@ -197,13 +197,13 @@ marker: null } #[test] -fn resolve_stored_param() -> Result<(), ParamsResolveError> { +fn resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_stored_param"), tynm::type_name::(), @@ -217,13 +217,13 @@ fn resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory() -> Result<(), ParamsResolveError> { +fn resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory"), tynm::type_name::(), @@ -237,9 +237,9 @@ fn resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { +fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_not_found"), tynm::type_name::(), @@ -255,14 +255,14 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemory { value_resolution_ctx }) + Err(ParamsResolveError::InMemory { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_not_found") && value_resolution_ctx.params_type_name() == "MockSrc" && value_resolution_ctx.resolution_chain().is_empty() ), - "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ + "expected `mock_src_result` to be `Err(ParamsResolveError::InMemory {{ .. }})`\n\ but was `{mock_src_result:?}`" ); } @@ -271,14 +271,13 @@ fn resolve_in_memory_returns_err_when_not_found() -> Result<(), ParamsResolveErr } #[test] -fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -295,7 +294,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_in_memory_returns_err_when_mutably_borrowed") @@ -303,7 +302,7 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -313,9 +312,9 @@ fn resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsRes } #[test] -fn resolve_value() -> Result<(), ParamsResolveError> { +fn resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_value"), tynm::type_name::(), @@ -329,13 +328,13 @@ fn resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn"), tynm::type_name::(), @@ -349,15 +348,14 @@ fn resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> -{ +fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -375,7 +373,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -384,7 +382,7 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -394,13 +392,13 @@ fn resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsRe } #[test] -fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { +fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_stored_param"), tynm::type_name::(), @@ -414,13 +412,13 @@ fn try_resolve_stored_param() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory"), tynm::type_name::(), @@ -434,9 +432,9 @@ fn try_resolve_in_memory() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_none_when_not_found"), tynm::type_name::(), @@ -450,14 +448,13 @@ fn try_resolve_in_memory_returns_none_when_not_found() -> Result<(), ParamsResol } #[test] -fn try_resolve_in_memory_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_in_memory_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(MockSrc(1)); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -474,7 +471,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) + Err(ParamsResolveError::InMemoryBorrowConflict { value_resolution_ctx }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_in_memory_returns_err_when_mutably_borrowed") @@ -482,7 +479,7 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() && value_resolution_ctx.resolution_chain().is_empty() ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::InMemoryBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); @@ -492,9 +489,9 @@ fn try_resolve_in_memory_returns_err_when_mutably_borrowed() } #[test] -fn try_resolve_value() -> Result<(), ParamsResolveError> { +fn try_resolve_value() -> Result<(), ParamsResolveError> { let resources = Resources::::from(Resources::new()); - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_value"), tynm::type_name::(), @@ -508,13 +505,13 @@ fn try_resolve_value() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn"), tynm::type_name::(), @@ -528,15 +525,14 @@ fn try_resolve_mapping_fn() -> Result<(), ParamsResolveError> { } #[test] -fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() --> Result<(), ParamsResolveError> { +fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() -> Result<(), ParamsResolveError> { let resources = { let mut resources = Resources::new(); resources.insert(1u8); resources.insert(2u16); Resources::::from(resources) }; - let mut value_resolution_ctx = ValueResolutionCtx::::new( + let mut value_resolution_ctx = ValueResolutionCtx::new( ValueResolutionMode::Current, item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed"), tynm::type_name::(), @@ -554,7 +550,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() assert!( matches!( &mock_src_result, - Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) + Err(ParamsResolveError::FromMapBorrowConflict { value_resolution_ctx, from_type_name }) if value_resolution_ctx.value_resolution_mode() == ValueResolutionMode::Current && value_resolution_ctx.item_id() == &item_id!("try_resolve_mapping_fn_returns_err_when_mutably_borrowed") @@ -563,7 +559,7 @@ fn try_resolve_mapping_fn_returns_err_when_mutably_borrowed() && from_type_name == "u16" ), "expected `mock_src_result` to be \ - `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ + `Err(ParamsResolveError::FromMapBorrowConflict {{ .. }})`\n\ with `resolution_chain`: `[]`,\n\ but was `{mock_src_result:?}`" ); diff --git a/workspace_tests/src/resources/resources.rs b/workspace_tests/src/resources/resources.rs index 805a7a3d5..89316ae50 100644 --- a/workspace_tests/src/resources/resources.rs +++ b/workspace_tests/src/resources/resources.rs @@ -36,6 +36,6 @@ fn resources_set_up_from_resources_empty() { let resources_set_up = Resources::::from(resources_empty); // no default resources - assert!(!resources_set_up.contains::>()); - assert!(!resources_set_up.contains::>()); + assert!(!resources_set_up.contains::()); + assert!(!resources_set_up.contains::()); } diff --git a/workspace_tests/src/resources/state_diffs.rs b/workspace_tests/src/resources/state_diffs.rs index c0c4caf92..0d37435ed 100644 --- a/workspace_tests/src/resources/state_diffs.rs +++ b/workspace_tests/src/resources/state_diffs.rs @@ -41,7 +41,7 @@ fn debug() { let state_diffs = test_state_diffs(); assert_eq!( - r#"StateDiffs({ItemId("key"): TypedValue { type: "i32", value: 123 }})"#, + r#"StateDiffs({ItemId("key"): TypedValue { type: "i32", value: 123 }})"#, format!("{state_diffs:?}") ); } diff --git a/workspace_tests/src/resources/states/states_cleaned_dry.rs b/workspace_tests/src/resources/states/states_cleaned_dry.rs index db19ccb7a..bc80160e7 100644 --- a/workspace_tests/src/resources/states/states_cleaned_dry.rs +++ b/workspace_tests/src/resources/states/states_cleaned_dry.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCleanedDry, StatesCurrent}; #[test] fn from_states_current() { - let _states_cleaned_dry = StatesCleanedDry::::from(StatesCurrent::new()); + let _states_cleaned_dry = StatesCleanedDry::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_current.rs b/workspace_tests/src/resources/states/states_current.rs index 062518318..61af6ca58 100644 --- a/workspace_tests/src/resources/states/states_current.rs +++ b/workspace_tests/src/resources/states/states_current.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesCurrentStored}; #[test] fn from_states_current_stored() { - let _states_current = StatesCurrent::from(StatesCurrentStored::::new()); + let _states_current = StatesCurrent::from(StatesCurrentStored::new()); } diff --git a/workspace_tests/src/resources/states/states_current_stored.rs b/workspace_tests/src/resources/states/states_current_stored.rs index 899956d54..cf94be9a0 100644 --- a/workspace_tests/src/resources/states/states_current_stored.rs +++ b/workspace_tests/src/resources/states/states_current_stored.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesCurrentStored}; #[test] fn from_states_current() { - let _states_current_stored = StatesCurrentStored::::from(StatesCurrent::new()); + let _states_current_stored = StatesCurrentStored::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_ensured.rs b/workspace_tests/src/resources/states/states_ensured.rs index 819f57bca..ab99aaeda 100644 --- a/workspace_tests/src/resources/states/states_ensured.rs +++ b/workspace_tests/src/resources/states/states_ensured.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesEnsured}; #[test] fn from_states_current() { - let _states_ensured = StatesEnsured::::from(StatesCurrent::new()); + let _states_ensured = StatesEnsured::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_ensured_dry.rs b/workspace_tests/src/resources/states/states_ensured_dry.rs index dcb959fc6..682b9739e 100644 --- a/workspace_tests/src/resources/states/states_ensured_dry.rs +++ b/workspace_tests/src/resources/states/states_ensured_dry.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesEnsuredDry}; #[test] fn from_states_current() { - let _states_ensured_dry = StatesEnsuredDry::::from(StatesCurrent::new()); + let _states_ensured_dry = StatesEnsuredDry::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/resources/states/states_goal.rs b/workspace_tests/src/resources/states/states_goal.rs index cbf08b2e4..b6234aae1 100644 --- a/workspace_tests/src/resources/states/states_goal.rs +++ b/workspace_tests/src/resources/states/states_goal.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesGoal, StatesGoalStored}; #[test] fn from_states_goal_stored() { - let _states_goal = StatesGoal::from(StatesGoalStored::::new()); + let _states_goal = StatesGoal::from(StatesGoalStored::new()); } diff --git a/workspace_tests/src/resources/states/states_goal_stored.rs b/workspace_tests/src/resources/states/states_goal_stored.rs index 8f4eb353d..27554623f 100644 --- a/workspace_tests/src/resources/states/states_goal_stored.rs +++ b/workspace_tests/src/resources/states/states_goal_stored.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesGoal, StatesGoalStored}; #[test] fn from_states_goal() { - let _states_goal_stored = StatesGoalStored::::from(StatesGoal::new()); + let _states_goal_stored = StatesGoalStored::from(StatesGoal::new()); } diff --git a/workspace_tests/src/resources/states/states_previous.rs b/workspace_tests/src/resources/states/states_previous.rs index 8310516e3..45e6f7902 100644 --- a/workspace_tests/src/resources/states/states_previous.rs +++ b/workspace_tests/src/resources/states/states_previous.rs @@ -2,5 +2,5 @@ use peace::resources::states::{StatesCurrent, StatesPrevious}; #[test] fn from_states_current() { - let _states_previous = StatesPrevious::::from(StatesCurrent::new()); + let _states_previous = StatesPrevious::from(StatesCurrent::new()); } diff --git a/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs index 3f591aa52..a96cefc96 100644 --- a/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/apply_exec_cmd_block.rs @@ -18,22 +18,10 @@ fn input_type_names_includes_states_current_and_states_target() { }; } - assert_input_type_names!( - Ensured, - &["States", "States"] - ); - assert_input_type_names!( - EnsuredDry, - &["States", "States"] - ); - assert_input_type_names!( - Cleaned, - &["States", "States"] - ); - assert_input_type_names!( - CleanedDry, - &["States", "States"] - ); + assert_input_type_names!(Ensured, &["States", "States"]); + assert_input_type_names!(EnsuredDry, &["States", "States"]); + assert_input_type_names!(Cleaned, &["States", "States"]); + assert_input_type_names!(CleanedDry, &["States", "States"]); } #[test] @@ -50,34 +38,18 @@ fn outcome_type_names_includes_states_previous_states_target() { assert_outcome_type_names!( Ensured, - &[ - "States", - "States", - "States" - ] + &["States", "States", "States"] ); assert_outcome_type_names!( EnsuredDry, - &[ - "States", - "States", - "States" - ] + &["States", "States", "States"] ); assert_outcome_type_names!( Cleaned, - &[ - "States", - "States", - "States" - ] + &["States", "States", "States"] ); assert_outcome_type_names!( CleanedDry, - &[ - "States", - "States", - "States" - ] + &["States", "States", "States"] ); } diff --git a/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs index 1e2c2d8c2..454ff82dd 100644 --- a/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/apply_state_sync_check_cmd_block.rs @@ -15,21 +15,15 @@ fn input_type_names_includes_states_compared() { } assert_input_type_names!(none, &[]); - assert_input_type_names!( - current, - &["States", "States"] - ); - assert_input_type_names!( - goal, - &["States", "States"] - ); + assert_input_type_names!(current, &["States", "States"]); + assert_input_type_names!(goal, &["States", "States"]); assert_input_type_names!( current_and_goal, &[ - "States", - "States", - "States", - "States" + "States", + "States", + "States", + "States" ] ); } @@ -47,21 +41,15 @@ fn outcome_type_names_includes_states_compared() { } assert_outcome_type_names!(none, &[]); - assert_outcome_type_names!( - current, - &["States", "States"] - ); - assert_outcome_type_names!( - goal, - &["States", "States"] - ); + assert_outcome_type_names!(current, &["States", "States"]); + assert_outcome_type_names!(goal, &["States", "States"]); assert_outcome_type_names!( current_and_goal, &[ - "States", - "States", - "States", - "States" + "States", + "States", + "States", + "States" ] ); } diff --git a/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs index e5f328640..0be3226cb 100644 --- a/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/diff_cmd_block.rs @@ -18,18 +18,11 @@ fn input_type_names_includes_states_ts0_and_states_ts1() { }; } - assert_input_type_names!( - Current, - Goal, - &["States", "States"] - ); + assert_input_type_names!(Current, Goal, &["States", "States"]); assert_input_type_names!( CurrentStored, GoalStored, - &[ - "States", - "States" - ] + &["States", "States"] ); } @@ -48,19 +41,11 @@ fn outcome_type_names_includes_state_diffs_states_ts0_and_states_ts1() { assert_outcome_type_names!( Current, Goal, - &[ - "StateDiffs", - "States", - "States" - ] + &["StateDiffs", "States", "States"] ); assert_outcome_type_names!( CurrentStored, GoalStored, - &[ - "StateDiffs", - "States", - "States" - ] + &["StateDiffs", "States", "States"] ); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs index 1043d95aa..127a0de7a 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_clean_insertion_cmd_block.rs @@ -17,5 +17,5 @@ fn outcome_type_names_includes_states_clean() { let outcome_type_names: Vec = cmd_block.outcome_type_names(); - assert_eq!(&["States"], outcome_type_names.as_slice()); + assert_eq!(&["States"], outcome_type_names.as_slice()); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs index 6f3c882a4..bfc44b178 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_current_read_cmd_block.rs @@ -17,8 +17,5 @@ fn outcome_type_names_includes_states_current_stored() { let outcome_type_names: Vec = cmd_block.outcome_type_names(); - assert_eq!( - &["States"], - outcome_type_names.as_slice() - ); + assert_eq!(&["States"], outcome_type_names.as_slice()); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs index c3b356ebe..2300c3825 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_discover_cmd_block.rs @@ -31,10 +31,7 @@ fn outcome_type_names_includes_states_compared() { }; } - assert_outcome_type_names!(current, &["States"]); - assert_outcome_type_names!(goal, &["States"]); - assert_outcome_type_names!( - current_and_goal, - &["States", "States"] - ); + assert_outcome_type_names!(current, &["States"]); + assert_outcome_type_names!(goal, &["States"]); + assert_outcome_type_names!(current_and_goal, &["States", "States"]); } diff --git a/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs b/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs index 06e906a6d..4a2ade018 100644 --- a/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs +++ b/workspace_tests/src/rt/cmd_blocks/states_goal_read_cmd_block.rs @@ -17,8 +17,5 @@ fn outcome_type_names_includes_states_goal_stored() { let outcome_type_names: Vec = cmd_block.outcome_type_names(); - assert_eq!( - &["States"], - outcome_type_names.as_slice() - ); + assert_eq!(&["States"], outcome_type_names.as_slice()); } diff --git a/workspace_tests/src/rt/cmds/diff_cmd.rs b/workspace_tests/src/rt/cmds/diff_cmd.rs index d4574a4e7..12b55487c 100644 --- a/workspace_tests/src/rt/cmds/diff_cmd.rs +++ b/workspace_tests/src/rt/cmds/diff_cmd.rs @@ -140,7 +140,7 @@ async fn diff_discover_current_on_demand() -> Result<(), Box>(); + let states_current = resources.borrow::(); let vec_diff = state_diffs.get::(VecCopyItem::ID_DEFAULT); let vec_copy_current_state = states_current.get::(VecCopyItem::ID_DEFAULT); @@ -215,7 +215,7 @@ async fn diff_discover_goal_on_demand() -> Result<(), Box // Note: discovered `StatesGoal` is not automatically serialized to storage. let resources = &cmd_ctx.view().resources; - let states_goal = resources.borrow::>(); + let states_goal = resources.borrow::(); let vec_diff = state_diffs.get::(VecCopyItem::ID_DEFAULT); let vec_copy_current_state = states_current.get::(VecCopyItem::ID_DEFAULT); @@ -284,8 +284,8 @@ async fn diff_discover_current_and_goal_on_demand() -> Result<(), Box>(); - let states_goal = resources.borrow::>(); + let states_current = resources.borrow::(); + let states_goal = resources.borrow::(); let vec_diff = state_diffs.get::(VecCopyItem::ID_DEFAULT); let vec_copy_current_state = states_current.get::(VecCopyItem::ID_DEFAULT); diff --git a/workspace_tests/src/rt/cmds/ensure_cmd.rs b/workspace_tests/src/rt/cmds/ensure_cmd.rs index e929ddf88..45f81fc5b 100644 --- a/workspace_tests/src/rt/cmds/ensure_cmd.rs +++ b/workspace_tests/src/rt/cmds/ensure_cmd.rs @@ -53,8 +53,8 @@ async fn resources_ensured_dry_does_not_alter_state() -> Result<(), Box`, - // but it would be useful to return simulated ensured states. + // The returned states are currently the same as `StatesCurrentStored`, but it + // would be useful to return simulated ensured states. let CmdOutcome::Complete { value: states_ensured_dry, cmd_blocks_processed: _, @@ -67,8 +67,8 @@ async fn resources_ensured_dry_does_not_alter_state() -> Result<(), Box>(); - // let states_goal = resources.borrow::>(); + // let states = resources.borrow::(); + // let states_goal = resources.borrow::(); // assert_eq!( // Some(VecCopyState::new()).as_ref(), // states.get::(&VecCopyItem::ID_DEFAULT) @@ -154,8 +154,8 @@ async fn resources_ensured_contains_state_ensured_for_each_item_when_state_not_y // was discovered. // // ```rust,ignore - // let ensured_states_before = resources_ensured.borrow::>(); - // let ensured_states_goal = resources_ensured.borrow::>(); + // let ensured_states_before = resources_ensured.borrow::(); + // let ensured_states_goal = resources_ensured.borrow::(); // assert_eq!( // Some(VecCopyState::new()).as_ref(), // ensured_states_before.get::(&VecCopyItem::ID_DEFAULT) diff --git a/workspace_tests/src/rt/cmds/states_discover_cmd.rs b/workspace_tests/src/rt/cmds/states_discover_cmd.rs index 3be8bb4ee..7faf068ce 100644 --- a/workspace_tests/src/rt/cmds/states_discover_cmd.rs +++ b/workspace_tests/src/rt/cmds/states_discover_cmd.rs @@ -194,7 +194,7 @@ async fn current_inserts_states_current_stored_from_states_current_file() // Writes to states_current_file.yaml StatesDiscoverCmd::current(&mut cmd_ctx).await?; - // Execute again to ensure StatesCurrentStored is included + // Execute again to ensure StatesCurrentStored is included // // Note: The actual logic is part of `CmdCtxBuilder::build`, implemented by // `impl_build.rs`. @@ -208,7 +208,7 @@ async fn current_inserts_states_current_stored_from_states_current_file() .await?; StatesDiscoverCmd::current(&mut cmd_ctx).await?; let resources = cmd_ctx.resources(); - let states_current_stored_from_cmd_ctx = resources.borrow::>(); + let states_current_stored_from_cmd_ctx = resources.borrow::(); let mut output = NoOpOutput; let mut cmd_ctx = CmdCtx::builder_single_profile_single_flow(&mut output, &workspace) diff --git a/workspace_tests/src/rt_model/item_wrapper.rs b/workspace_tests/src/rt_model/item_wrapper.rs index c3468528e..984ed3b03 100644 --- a/workspace_tests/src/rt_model/item_wrapper.rs +++ b/workspace_tests/src/rt_model/item_wrapper.rs @@ -660,7 +660,7 @@ async fn resources_set_up( async fn resources_set_up_with_pre_stored_state( item_wrapper: &VecCopyItemWrapper, -) -> Result<(ParamsSpecs, Resources, StatesCurrent), VecCopyError> { +) -> Result<(ParamsSpecs, Resources, StatesCurrent), VecCopyError> { let (params_specs, mut resources) = resources_set_up(item_wrapper).await?; let stored_state = vec![0, 1, 2, 3, 4, 5, 6, 7]; resources.insert(VecB(stored_state.clone())); @@ -683,8 +683,8 @@ async fn resources_and_states_current_stored_and_goal( ( ParamsSpecs, Resources, - StatesCurrentStored, - StatesGoal, + StatesCurrentStored, + StatesGoal, ), VecCopyError, > { @@ -717,7 +717,7 @@ async fn resources_and_states_current_stored_and_goal( states_mut.insert_raw(>::id(item_wrapper).clone(), state); } - Into::>::into(StatesCurrent::from(states_mut)) + Into::::into(StatesCurrent::from(states_mut)) }; let states_goal = { let mut states_goal_mut = StatesMut::::new(); diff --git a/workspace_tests/src/rt_model/output/cli_output.rs b/workspace_tests/src/rt_model/output/cli_output.rs index 00c0be47c..205fc383e 100644 --- a/workspace_tests/src/rt_model/output/cli_output.rs +++ b/workspace_tests/src/rt_model/output/cli_output.rs @@ -38,7 +38,7 @@ async fn outputs_states_as_text() -> Result<(), Box> { let mut states = StatesMut::new(); states.insert(item_id!("item_0"), State::new("logical", 1.1)); states.insert(item_id!("item_1"), State::new(1u8, true)); - StatesCurrentStored::::from(states) + StatesCurrentStored::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; @@ -99,7 +99,7 @@ async fn outputs_states_as_text_colorized() -> Result<(), Box::from(states) + StatesCurrentStored::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; @@ -174,7 +174,7 @@ async fn outputs_states_as_yaml() -> Result<(), Box> { let mut states = StatesMut::new(); states.insert(item_id!("item_0"), State::new("logical", 1.1)); states.insert(item_id!("item_1"), State::new(1u8, true)); - StatesCurrentStored::::from(states) + StatesCurrentStored::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; @@ -238,7 +238,7 @@ async fn outputs_states_as_json() -> Result<(), Box> { let mut states = StatesMut::new(); states.insert(item_id!("item_0"), State::new("logical", 1.1)); states.insert(item_id!("item_1"), State::new(1u8, true)); - StatesCurrentStored::::from(states) + StatesCurrentStored::from(states) }; as OutputWrite>::present(&mut cli_output, &states_current_stored).await?; diff --git a/workspace_tests/src/rt_model/states_serializer.rs b/workspace_tests/src/rt_model/states_serializer.rs index 2a1c0ec1c..7203e7ccd 100644 --- a/workspace_tests/src/rt_model/states_serializer.rs +++ b/workspace_tests/src/rt_model/states_serializer.rs @@ -36,7 +36,7 @@ async fn serialize() -> Result<(), Box> { let mut states_mut = StatesMut::new(); states_mut.insert(item_one.clone(), VecCopyState::from(vec![1u8])); states_mut.insert(item_two.clone(), MockState(2u8)); - StatesCurrentStored::::from(states_mut) + StatesCurrentStored::from(states_mut) }; StatesSerializer::::serialize( &storage, @@ -83,7 +83,7 @@ async fn deserialize_stored() -> Result<(), Box> { let mut states_mut = StatesMut::new(); states_mut.insert(item_one.clone(), VecCopyState::from(vec![1u8])); states_mut.insert(item_two.clone(), MockState(2u8)); - StatesCurrentStored::::from(states_mut) + StatesCurrentStored::from(states_mut) }; let mut states_type_reg = TypeReg::new_typed(); states_type_reg.register::(item_one.clone()); diff --git a/workspace_tests/src/vec_copy_item.rs b/workspace_tests/src/vec_copy_item.rs index 4927e5915..6bf943378 100644 --- a/workspace_tests/src/vec_copy_item.rs +++ b/workspace_tests/src/vec_copy_item.rs @@ -208,10 +208,8 @@ impl Item for VecCopyItem { async fn setup(&self, resources: &mut Resources) -> Result<(), VecCopyError> { let vec_b = { - let states_current_stored = > as Data>::borrow( - Self::ID_DEFAULT, - resources, - ); + let states_current_stored = + as Data>::borrow(Self::ID_DEFAULT, resources); let vec_copy_state_current_stored: Option<&'_ VecCopyState> = states_current_stored .as_ref() .and_then(|states_current_stored| states_current_stored.get(self.id())); From 6269e3983ea537bd6dfd7908bb81c554ba504e3f Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Thu, 1 Feb 2024 18:32:01 +1300 Subject: [PATCH 5/7] Revert "Text replace `ItemId` with `ItemidT`." This reverts commit 8c942939a47a7c1f5ccb6730ec8d1e7e443ad1b2. --- crate/cfg/src/accessors/stored.rs | 20 +++++++---------- crate/cfg/src/fn_ctx.rs | 4 ++-- crate/cmd_model/src/cmd_block_outcome.rs | 2 +- crate/cmd_model/src/cmd_outcome.rs | 2 +- .../src/stream_outcome_and_errors.rs | 2 +- crate/cmd_rt/src/cmd_block/cmd_block_error.rs | 2 +- crate/cmd_rt/src/progress.rs | 8 +++---- crate/code_gen/src/cmd/impl_common_fns.rs | 2 +- crate/code_gen/src/cmd/struct_definition.rs | 4 ++-- crate/core/src/lib.rs | 2 +- crate/core/src/progress/progress_sender.rs | 6 ++--- .../src/progress/progress_update_and_id.rs | 4 ++-- crate/data/src/accessors/r_maybe.rs | 5 ++--- crate/data/src/accessors/w_maybe.rs | 5 ++--- crate/data/src/data.rs | 21 +++++------------- crate/data_derive/src/lib.rs | 2 +- crate/params/src/params_specs.rs | 12 +++++----- crate/params/src/value_resolution_ctx.rs | 4 ++-- .../resources/src/internal/state_diffs_mut.rs | 16 +++++++------- crate/resources/src/internal/states_mut.rs | 16 +++++++------- crate/resources/src/states.rs | 16 +++++++------- crate/resources/src/states/state_diffs.rs | 12 +++++----- crate/resources/src/states/states_serde.rs | 22 +++++++++---------- .../rt/src/cmd_blocks/apply_exec_cmd_block.rs | 10 ++++----- crate/rt/src/cmd_blocks/diff_cmd_block.rs | 4 ++-- .../states_current_read_cmd_block.rs | 2 +- .../cmd_blocks/states_discover_cmd_block.rs | 18 +++++++-------- .../cmd_blocks/states_goal_read_cmd_block.rs | 2 +- crate/rt/src/cmds/diff_cmd.rs | 6 ++--- crate/rt_model/src/item_rt.rs | 4 ++-- crate/rt_model/src/item_wrapper.rs | 8 +++---- crate/rt_model/src/params_specs_type_reg.rs | 4 ++-- crate/rt_model/src/states_serializer.rs | 10 ++++----- crate/rt_model/src/states_type_reg.rs | 4 ++-- .../rt_model_core/src/cmd_progress_tracker.rs | 8 +++---- crate/rt_model_core/src/error.rs | 4 ++-- .../src/items_state_stored_stale.rs | 12 +++++----- examples/download/src/lib.rs | 2 +- .../peace_aws_iam_policy/iam_policy_item.rs | 2 +- .../items/peace_aws_iam_role/iam_role_item.rs | 2 +- .../instance_profile_item.rs | 2 +- .../peace_aws_s3_bucket/s3_bucket_item.rs | 2 +- .../peace_aws_s3_object/s3_object_item.rs | 2 +- examples/envman/src/output.rs | 4 ++-- examples/envman/src/web/flow_dot_renderer.rs | 4 ++-- items/blank/src/blank_item.rs | 2 +- items/file_download/src/file_download_item.rs | 4 ++-- items/sh_cmd/src/sh_cmd_item.rs | 4 ++-- items/tar_x/src/tar_x_item.rs | 2 +- workspace_tests/src/cfg/item_id.rs | 2 +- workspace_tests/src/items/sh_cmd_item.rs | 2 +- workspace_tests/src/items/tar_x_item.rs | 2 +- workspace_tests/src/mock_item.rs | 2 +- .../src/rt/cmds/states_discover_cmd.rs | 2 +- workspace_tests/src/vec_copy_item.rs | 2 +- 55 files changed, 156 insertions(+), 173 deletions(-) diff --git a/crate/cfg/src/accessors/stored.rs b/crate/cfg/src/accessors/stored.rs index 30c3ae3db..bd06692b0 100644 --- a/crate/cfg/src/accessors/stored.rs +++ b/crate/cfg/src/accessors/stored.rs @@ -17,35 +17,31 @@ use serde::Serialize; /// The previously stored `T` state, if any. #[derive(Debug)] -pub struct Stored<'borrow, ItemIdT, T> { +pub struct Stored<'borrow, T> { /// ID of the item the state should be retrieved for. - item_id: ItemIdT, + item_id: &'borrow ItemId, /// The borrowed `StatesCurrentStored`. states_current_stored: Option>, /// Marker. marker: PhantomData, } -impl<'borrow, ItemIdT, T> Stored<'borrow, ItemIdT, T> +impl<'borrow, T> Stored<'borrow, T> where - ItemIdT: ItemId, T: Clone + Debug + DataType + Display + Serialize + Send + Sync + 'static, { pub fn get(&'borrow self) -> Option<&'borrow T> { self.states_current_stored .as_ref() - .and_then(|states_current_stored| states_current_stored.get(&self.item_id)) + .and_then(|states_current_stored| states_current_stored.get(self.item_id)) } } -impl<'borrow, ItemIdT, T> Data<'borrow> for Stored<'borrow, ItemIdT, T> +impl<'borrow, T> Data<'borrow> for Stored<'borrow, T> where - ItemIdT: ItemId, T: Debug + Send + Sync + 'static, { - type ItemId = ItemIdT; - - fn borrow(item_id: &'borrow ItemIdT, resources: &'borrow Resources) -> Self { + fn borrow(item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { let states_current_stored = resources .try_borrow::() .map_err(|borrow_fail| match borrow_fail { @@ -64,7 +60,7 @@ where } } -impl<'borrow, ItemIdT, T> DataAccess for Stored<'borrow, ItemIdT, T> { +impl<'borrow, T> DataAccess for Stored<'borrow, T> { fn borrows() -> TypeIds where Self: Sized, @@ -82,7 +78,7 @@ impl<'borrow, ItemIdT, T> DataAccess for Stored<'borrow, ItemIdT, T> { } } -impl<'borrow, ItemIdT, T> DataAccessDyn for Stored<'borrow, ItemIdT, T> { +impl<'borrow, T> DataAccessDyn for Stored<'borrow, T> { fn borrows(&self) -> TypeIds where Self: Sized, diff --git a/crate/cfg/src/fn_ctx.rs b/crate/cfg/src/fn_ctx.rs index 50a061efc..31289bd31 100644 --- a/crate/cfg/src/fn_ctx.rs +++ b/crate/cfg/src/fn_ctx.rs @@ -9,7 +9,7 @@ use peace_core::progress::ProgressSender; #[derive(Clone, Copy, Debug)] pub struct FnCtx<'exec> { /// ID of the item this belongs to. - pub item_id: &'exec ItemIdT, + pub item_id: &'exec ItemId, /// For items to submit progress updates. #[cfg(feature = "output_progress")] pub progress_sender: ProgressSender<'exec>, @@ -20,7 +20,7 @@ pub struct FnCtx<'exec> { impl<'exec> FnCtx<'exec> { /// Returns a new `OpCtx`. pub fn new( - item_id: &'exec ItemIdT, + item_id: &'exec ItemId, #[cfg(feature = "output_progress")] progress_sender: ProgressSender<'exec>, ) -> Self { Self { diff --git a/crate/cmd_model/src/cmd_block_outcome.rs b/crate/cmd_model/src/cmd_block_outcome.rs index b65506f41..5092d7095 100644 --- a/crate/cmd_model/src/cmd_block_outcome.rs +++ b/crate/cmd_model/src/cmd_block_outcome.rs @@ -39,7 +39,7 @@ pub enum CmdBlockOutcome { /// The values returned per item. stream_outcome: StreamOutcome, /// Errors from the command execution. - errors: IndexMap, + errors: IndexMap, }, } diff --git a/crate/cmd_model/src/cmd_outcome.rs b/crate/cmd_model/src/cmd_outcome.rs index 1c3a9db56..643e7353d 100644 --- a/crate/cmd_model/src/cmd_outcome.rs +++ b/crate/cmd_model/src/cmd_outcome.rs @@ -60,7 +60,7 @@ pub enum CmdOutcome { /// The first block in this list is the one that erred. cmd_blocks_not_processed: Vec, /// Item error(s) from the last command block's execution. - errors: IndexMap, + errors: IndexMap, }, } diff --git a/crate/cmd_model/src/stream_outcome_and_errors.rs b/crate/cmd_model/src/stream_outcome_and_errors.rs index 1e525f04b..852ec4f3d 100644 --- a/crate/cmd_model/src/stream_outcome_and_errors.rs +++ b/crate/cmd_model/src/stream_outcome_and_errors.rs @@ -8,5 +8,5 @@ pub struct StreamOutcomeAndErrors { /// The `CmdBlock` stream outcome. pub stream_outcome: StreamOutcome, /// The errors during processing, - pub errors: IndexMap, + pub errors: IndexMap, } diff --git a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs index 896c6612a..c4f9a031a 100644 --- a/crate/cmd_rt/src/cmd_block/cmd_block_error.rs +++ b/crate/cmd_rt/src/cmd_block/cmd_block_error.rs @@ -44,7 +44,7 @@ where /// The outcome value. stream_outcome: StreamOutcome, /// Item error(s) from the last command block's execution. - errors: IndexMap, + errors: IndexMap, }, /// An interrupt signal was received while the `CmdBlock` was executing. #[error("`CmdBlock` item logic failed.")] diff --git a/crate/cmd_rt/src/progress.rs b/crate/cmd_rt/src/progress.rs index b9e45746e..5f120d45e 100644 --- a/crate/cmd_rt/src/progress.rs +++ b/crate/cmd_rt/src/progress.rs @@ -6,7 +6,7 @@ use peace_cfg::{ CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressStatus, ProgressTracker, ProgressUpdate, ProgressUpdateAndId, }, - ItemIdT, + ItemId, }; use peace_rt_model::{output::OutputWrite, IndexMap}; use tokio::sync::mpsc::Receiver; @@ -18,7 +18,7 @@ impl Progress { // TODO: write test for this pub async fn progress_render( output: &mut O, - progress_trackers: &mut IndexMap, + progress_trackers: &mut IndexMap, mut cmd_progress_rx: Receiver, ) where O: OutputWrite, @@ -32,7 +32,7 @@ impl Progress { async fn handle_cmd_progress_update( output: &mut O, - progress_trackers: &mut IndexMap, + progress_trackers: &mut IndexMap, cmd_progress_update: CmdProgressUpdate, ) -> ControlFlow<()> where @@ -102,7 +102,7 @@ impl Progress { async fn handle_progress_update_and_id( output: &mut O, - progress_trackers: &mut IndexMap, + progress_trackers: &mut IndexMap, progress_update_and_id: ProgressUpdateAndId, ) where O: OutputWrite, diff --git a/crate/code_gen/src/cmd/impl_common_fns.rs b/crate/code_gen/src/cmd/impl_common_fns.rs index 545748ca7..ad58c50fb 100644 --- a/crate/code_gen/src/cmd/impl_common_fns.rs +++ b/crate/code_gen/src/cmd/impl_common_fns.rs @@ -39,7 +39,7 @@ pub fn impl_common_fns(scope_struct: &ScopeStruct) -> proc_macro2::TokenStream { /// Note: this **must** be called for each item in the flow. pub fn with_item_params( mut self, - item_id: peace_cfg::ItemIdT, + item_id: peace_cfg::ItemId, params_spec: as peace_params::Params>::Spec, ) -> Self where diff --git a/crate/code_gen/src/cmd/struct_definition.rs b/crate/code_gen/src/cmd/struct_definition.rs index ee290a433..f4b2c53c6 100644 --- a/crate/code_gen/src/cmd/struct_definition.rs +++ b/crate/code_gen/src/cmd/struct_definition.rs @@ -37,7 +37,7 @@ use crate::cmd::scope_struct::ScopeStruct; /// pub(crate) profile_params_selection: CmdCtxBuilderTypesT::ProfileParamsSelection, /// /// Flow parameters. /// pub(crate) flow_params_selection: CmdCtxBuilderTypesT::FlowParamsSelection, -/// /// Map of item ID to its parameters. `TypeMap` newtype. +/// /// Map of item ID to its parameters. `TypeMap` newtype. /// pub(crate) params_specs_provided: peace_params::ParamsSpecs, /// } /// ``` @@ -129,7 +129,7 @@ mod fields { pub fn params_specs_push(fields_named: &mut FieldsNamed, scope: Scope) { if scope.flow_count() == FlowCount::One { let fields_params_specs: FieldsNamed = parse_quote!({ - /// Map of item ID to its parameters. `TypeMap` newtype. + /// Map of item ID to its parameters. `TypeMap` newtype. pub(crate) params_specs_provided: peace_params::ParamsSpecs }); fields_named.named.extend(fields_params_specs.named); diff --git a/crate/core/src/lib.rs b/crate/core/src/lib.rs index 594f56449..565f70de9 100644 --- a/crate/core/src/lib.rs +++ b/crate/core/src/lib.rs @@ -4,7 +4,7 @@ //! //! * `peace_cfg` has a dependency on `peace_resources` for `Resources`, used in //! `Item::setup`. -//! * `peace_resources` has a dependency on `ItemId`, as uses `TypeMap` for the `States` maps. //! //! When [peace#67] is implemented, the `progress` module can be moved out diff --git a/crate/core/src/progress/progress_sender.rs b/crate/core/src/progress/progress_sender.rs index f75c3469e..ba228306b 100644 --- a/crate/core/src/progress/progress_sender.rs +++ b/crate/core/src/progress/progress_sender.rs @@ -4,21 +4,21 @@ use crate::{ progress::{ CmdProgressUpdate, ProgressDelta, ProgressMsgUpdate, ProgressUpdate, ProgressUpdateAndId, }, - ItemIdT, + ItemId, }; /// Submits progress for an item's `ApplyFns::exec` method. #[derive(Clone, Copy, Debug)] pub struct ProgressSender<'exec> { /// ID of the item this belongs to. - item_id: &'exec ItemIdT, + item_id: &'exec ItemId, /// Channel sender to send progress updates to. progress_tx: &'exec Sender, } impl<'exec> ProgressSender<'exec> { /// Returns a new `ProgressSender`. - pub fn new(item_id: &'exec ItemIdT, progress_tx: &'exec Sender) -> Self { + pub fn new(item_id: &'exec ItemId, progress_tx: &'exec Sender) -> Self { Self { item_id, progress_tx, diff --git a/crate/core/src/progress/progress_update_and_id.rs b/crate/core/src/progress/progress_update_and_id.rs index 8306f486b..7d34a43c5 100644 --- a/crate/core/src/progress/progress_update_and_id.rs +++ b/crate/core/src/progress/progress_update_and_id.rs @@ -2,14 +2,14 @@ use serde::{Deserialize, Serialize}; use crate::{ progress::{ProgressMsgUpdate, ProgressUpdate}, - ItemIdT, + ItemId, }; /// An item ID and its progress update. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct ProgressUpdateAndId { /// ID of the item whose progress is updated. - pub item_id: ItemIdT, + pub item_id: ItemId, /// Delta update for the progress tracker. pub progress_update: ProgressUpdate, /// Whether to change the progress message. diff --git a/crate/data/src/accessors/r_maybe.rs b/crate/data/src/accessors/r_maybe.rs index dbe492fc8..e21ea9a1f 100644 --- a/crate/data/src/accessors/r_maybe.rs +++ b/crate/data/src/accessors/r_maybe.rs @@ -4,6 +4,7 @@ use fn_graph::{ resman::{BorrowFail, Ref}, DataAccess, DataAccessDyn, Resources, TypeIds, }; +use peace_core::ItemId; use crate::Data; @@ -41,9 +42,7 @@ impl<'borrow, T> Data<'borrow> for RMaybe<'borrow, T> where T: Debug + Send + Sync + 'static, { - type ItemId = (); - - fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { + fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { resources .try_borrow::() .map_err(|borrow_fail| match borrow_fail { diff --git a/crate/data/src/accessors/w_maybe.rs b/crate/data/src/accessors/w_maybe.rs index 9cbede839..13d06d8c3 100644 --- a/crate/data/src/accessors/w_maybe.rs +++ b/crate/data/src/accessors/w_maybe.rs @@ -4,6 +4,7 @@ use fn_graph::{ resman::{BorrowFail, RefMut}, DataAccess, DataAccessDyn, Resources, TypeIds, }; +use peace_core::ItemId; use crate::Data; @@ -50,9 +51,7 @@ impl<'borrow, T> Data<'borrow> for WMaybe<'borrow, T> where T: Debug + Send + Sync + 'static, { - type ItemId = (); - - fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { + fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { resources .try_borrow_mut::() .map_err(|borrow_fail| match borrow_fail { diff --git a/crate/data/src/data.rs b/crate/data/src/data.rs index 144bf355d..15ff4f6e7 100644 --- a/crate/data/src/data.rs +++ b/crate/data/src/data.rs @@ -11,9 +11,6 @@ use peace_core::ItemId; /// /// [`Data` derive]: peace_data_derive::Data pub trait Data<'borrow>: DataAccess + DataAccessDyn + Send { - /// The `ItemId` enum defined by the application software. - type ItemId: ItemId; - /// Borrows each of `Self`'s fields from the provided [`Resources`]. /// /// This takes in the `item_id`, so that the type that implements this @@ -24,19 +21,15 @@ pub trait Data<'borrow>: DataAccess + DataAccessDyn + Send { /// /// * `item_id`: ID of the item this borrow is used for. /// * `resources`: `Any` map to borrow the data from. - fn borrow(item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self; + fn borrow(item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self; } impl<'borrow> Data<'borrow> for () { - type ItemId = (); - - fn borrow(_item_id: &'borrow Self::ItemId, _resources: &'borrow Resources) -> Self {} + fn borrow(_item_id: &'borrow ItemId, _resources: &'borrow Resources) -> Self {} } impl<'borrow> Data<'borrow> for &'borrow () { - type ItemId = (); - - fn borrow(_item_id: &'borrow Self::ItemId, _resources: &'borrow Resources) -> Self { + fn borrow(_item_id: &'borrow ItemId, _resources: &'borrow Resources) -> Self { &() } } @@ -45,9 +38,7 @@ impl<'borrow, T> Data<'borrow> for R<'borrow, T> where T: Debug + Send + Sync + 'static, { - type ItemId = (); - - fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { + fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { ::borrow(resources) } } @@ -56,9 +47,7 @@ impl<'borrow, T> Data<'borrow> for W<'borrow, T> where T: Debug + Send + Sync + 'static, { - type ItemId = (); - - fn borrow(_item_id: &'borrow Self::ItemId, resources: &'borrow Resources) -> Self { + fn borrow(_item_id: &'borrow ItemId, resources: &'borrow Resources) -> Self { ::borrow(resources) } } diff --git a/crate/data_derive/src/lib.rs b/crate/data_derive/src/lib.rs index e2989c15a..05091fe23 100644 --- a/crate/data_derive/src/lib.rs +++ b/crate/data_derive/src/lib.rs @@ -121,7 +121,7 @@ fn impl_data_access(ast: &DeriveInput) -> proc_macro2::TokenStream { for #name #ty_generics #where_clause { - fn borrow(item_id: & #impl_borrow_lt #peace_cfg_path::ItemIdT, resources: & #impl_borrow_lt #peace_data_path::Resources) -> Self { + fn borrow(item_id: & #impl_borrow_lt #peace_cfg_path::ItemId, resources: & #impl_borrow_lt #peace_data_path::Resources) -> Self { #borrow_return } } diff --git a/crate/params/src/params_specs.rs b/crate/params/src/params_specs.rs index 76d3d06ad..56e9a7b10 100644 --- a/crate/params/src/params_specs.rs +++ b/crate/params/src/params_specs.rs @@ -6,7 +6,7 @@ use serde::Serialize; use crate::AnySpecRtBoxed; -/// Map of item ID to its params' specs. `TypeMap` newtype. /// /// The concrete `*ValueSpec` type can be obtained by calling @@ -26,7 +26,7 @@ use crate::AnySpecRtBoxed; /// different in what they are doing. #[derive(Clone, Debug, Default, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct ParamsSpecs(TypeMap); +pub struct ParamsSpecs(TypeMap); impl ParamsSpecs { /// Returns a new `ParamsSpecs` map. @@ -44,13 +44,13 @@ impl ParamsSpecs { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } impl Deref for ParamsSpecs { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -63,8 +63,8 @@ impl DerefMut for ParamsSpecs { } } -impl From> for ParamsSpecs { - fn from(type_map: TypeMap) -> Self { +impl From> for ParamsSpecs { + fn from(type_map: TypeMap) -> Self { Self(type_map) } } diff --git a/crate/params/src/value_resolution_ctx.rs b/crate/params/src/value_resolution_ctx.rs index f9c753345..7f9edc240 100644 --- a/crate/params/src/value_resolution_ctx.rs +++ b/crate/params/src/value_resolution_ctx.rs @@ -11,7 +11,7 @@ pub struct ValueResolutionCtx { /// `Goal`. value_resolution_mode: ValueResolutionMode, /// ID of the item whose params are being resolved. - item_id: ItemIdT, + item_id: ItemId, /// Name of the `Item::Params` type. params_type_name: String, /// Hierarchy of fields traversed to resolve this value. @@ -21,7 +21,7 @@ pub struct ValueResolutionCtx { impl ValueResolutionCtx { pub fn new( value_resolution_mode: ValueResolutionMode, - item_id: ItemIdT, + item_id: ItemId, params_type_name: String, ) -> Self { Self { diff --git a/crate/resources/src/internal/state_diffs_mut.rs b/crate/resources/src/internal/state_diffs_mut.rs index 347769299..270dfc24e 100644 --- a/crate/resources/src/internal/state_diffs_mut.rs +++ b/crate/resources/src/internal/state_diffs_mut.rs @@ -4,7 +4,7 @@ use peace_core::ItemId; use serde::Serialize; use type_reg::untagged::{BoxDtDisplay, TypeMap}; -/// Diffs of `State`s for each `Item`s. `TypeMap` +/// Diffs of `State`s for each `Item`s. `TypeMap` /// newtype. /// /// # Implementors @@ -15,7 +15,7 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// [`StateDiffs`]: crate::StateDiffs /// [`Resources`]: crate::Resources #[derive(Debug, Default, Serialize)] -pub struct StateDiffsMut(TypeMap); +pub struct StateDiffsMut(TypeMap); impl StateDiffsMut { /// Returns a new `StateDiffsMut` map. @@ -32,13 +32,13 @@ impl StateDiffsMut { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } impl Deref for StateDiffsMut { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -51,14 +51,14 @@ impl DerefMut for StateDiffsMut { } } -impl From> for StateDiffsMut { - fn from(type_map: TypeMap) -> Self { +impl From> for StateDiffsMut { + fn from(type_map: TypeMap) -> Self { Self(type_map) } } -impl Extend<(ItemIdT, BoxDtDisplay)> for StateDiffsMut { - fn extend>(&mut self, iter: T) { +impl Extend<(ItemId, BoxDtDisplay)> for StateDiffsMut { + fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state_diff)| { self.insert_raw(item_id, state_diff); }); diff --git a/crate/resources/src/internal/states_mut.rs b/crate/resources/src/internal/states_mut.rs index 089ef86ac..f76b7eb1c 100644 --- a/crate/resources/src/internal/states_mut.rs +++ b/crate/resources/src/internal/states_mut.rs @@ -7,7 +7,7 @@ use peace_core::ItemId; use serde::Serialize; use type_reg::untagged::{BoxDtDisplay, TypeMap}; -/// `State`s for all `Item`s. `TypeMap` newtype. +/// `State`s for all `Item`s. `TypeMap` newtype. /// /// # Implementors /// @@ -26,7 +26,7 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; /// [`StatesCurrent`]: crate::StatesCurrent /// [`StatesRw`]: crate::StatesRw #[derive(Debug, Serialize)] -pub struct StatesMut(TypeMap, PhantomData); +pub struct StatesMut(TypeMap, PhantomData); impl StatesMut { /// Returns a new `StatesMut` map. @@ -43,7 +43,7 @@ impl StatesMut { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } @@ -55,7 +55,7 @@ impl Default for StatesMut { } impl Deref for StatesMut { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 @@ -68,14 +68,14 @@ impl DerefMut for StatesMut { } } -impl From> for StatesMut { - fn from(type_map: TypeMap) -> Self { +impl From> for StatesMut { + fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } -impl Extend<(ItemIdT, BoxDtDisplay)> for StatesMut { - fn extend>(&mut self, iter: T) { +impl Extend<(ItemId, BoxDtDisplay)> for StatesMut { + fn extend>(&mut self, iter: T) { iter.into_iter().for_each(|(item_id, state)| { self.insert_raw(item_id, state); }); diff --git a/crate/resources/src/states.rs b/crate/resources/src/states.rs index de5249eae..6a352dc8e 100644 --- a/crate/resources/src/states.rs +++ b/crate/resources/src/states.rs @@ -33,7 +33,7 @@ mod states_goal_stored; mod states_previous; mod states_serde; -/// Map of `State`s for all `Item`s. `TypeMap` newtype. +/// Map of `State`s for all `Item`s. `TypeMap` newtype. /// /// # Type Parameters /// @@ -51,7 +51,7 @@ mod states_serde; /// regardless of whether a `State` is recorded for that item. /// /// 2. Inserting an `Option<_>` layer around the `Item::State` turns the map -/// into a `Map>`. +/// into a `Map>`. /// /// 3. Calling `states.get(item_id)` returns `Option>`, the /// outer layer for whether the item had an entry, and the inner layer for @@ -92,7 +92,7 @@ mod states_serde; /// /// ## `StatesSerde` Separate Type /// -/// Newtype for `Map>`. +/// Newtype for `Map>`. /// /// ### Item Additions /// @@ -146,7 +146,7 @@ mod states_serde; #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. pub struct States( - pub(crate) TypeMap, + pub(crate) TypeMap, pub(crate) PhantomData, ); @@ -165,7 +165,7 @@ impl States { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } @@ -190,15 +190,15 @@ impl Default for States { } impl Deref for States { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 } } -impl From> for States { - fn from(type_map: TypeMap) -> Self { +impl From> for States { + fn from(type_map: TypeMap) -> Self { Self(type_map, PhantomData) } } diff --git a/crate/resources/src/states/state_diffs.rs b/crate/resources/src/states/state_diffs.rs index 0bc95c56c..34b56948a 100644 --- a/crate/resources/src/states/state_diffs.rs +++ b/crate/resources/src/states/state_diffs.rs @@ -7,7 +7,7 @@ use type_reg::untagged::{BoxDtDisplay, TypeMap}; use crate::internal::StateDiffsMut; -/// Diffs of `State`s for each `Item`s. `TypeMap` +/// Diffs of `State`s for each `Item`s. `TypeMap` /// newtype. /// /// [`External`] fields are not necessarily used in `StateDiff` computations. @@ -20,7 +20,7 @@ use crate::internal::StateDiffsMut; /// [`External`]: peace_cfg::state::External /// [`Resources`]: crate::Resources #[derive(Debug, Default, Serialize)] -pub struct StateDiffs(TypeMap); +pub struct StateDiffs(TypeMap); impl StateDiffs { /// Returns a new `StateDiffs` map. @@ -37,21 +37,21 @@ impl StateDiffs { } /// Returns the inner map. - pub fn into_inner(self) -> TypeMap { + pub fn into_inner(self) -> TypeMap { self.0 } } impl Deref for StateDiffs { - type Target = TypeMap; + type Target = TypeMap; fn deref(&self) -> &Self::Target { &self.0 } } -impl From> for StateDiffs { - fn from(type_map: TypeMap) -> Self { +impl From> for StateDiffs { + fn from(type_map: TypeMap) -> Self { Self(type_map) } } diff --git a/crate/resources/src/states/states_serde.rs b/crate/resources/src/states/states_serde.rs index c5aea647b..4077e58a2 100644 --- a/crate/resources/src/states/states_serde.rs +++ b/crate/resources/src/states/states_serde.rs @@ -9,10 +9,10 @@ use type_reg::{ untagged::{BoxDtDisplay, TypeMapOpt}, }; -/// Map of `State`s for all `Item`s. `TypeMapOpt` +/// Map of `State`s for all `Item`s. `TypeMapOpt` /// newtype. /// -/// Conceptually you can think of this as a `Map>`. +/// Conceptually you can think of this as a `Map>`. /// /// This map should: /// @@ -23,12 +23,12 @@ use type_reg::{ /// /// * Deserialization. /// * `From<&ItemGraph>`: All states are initialized to `None`. -/// * [`FromIterator::<(ItemIdT, Option)>::from_iter`]. +/// * [`FromIterator::<(ItemId, Option)>::from_iter`]. /// -/// [`FromIterator::<(ItemIdT, Option)>::from_iter`]: std::iter::FromIterator +/// [`FromIterator::<(ItemId, Option)>::from_iter`]: std::iter::FromIterator #[derive(Debug, Serialize)] #[serde(transparent)] // Needed to serialize as a map instead of a list. -pub struct StatesSerde(TypeMapOpt>) +pub struct StatesSerde(TypeMapOpt>) where ValueT: Clone + Debug + PartialEq + Eq; @@ -45,7 +45,7 @@ where } /// Returns the inner map. - pub fn into_inner(self) -> TypeMapOpt> { + pub fn into_inner(self) -> TypeMapOpt> { self.0 } } @@ -70,18 +70,18 @@ impl Deref for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, { - type Target = TypeMapOpt>; + type Target = TypeMapOpt>; fn deref(&self) -> &Self::Target { &self.0 } } -impl FromIterator<(ItemIdT, Option)> for StatesSerde +impl FromIterator<(ItemId, Option)> for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, { - fn from_iter)>>(iter: T) -> Self { + fn from_iter)>>(iter: T) -> Self { iter.into_iter().fold( Self(TypeMapOpt::new_typed()), |mut states_serde, (item_id, state_boxed)| { @@ -92,12 +92,12 @@ where } } -impl From>> +impl From>> for StatesSerde where ValueT: Clone + Debug + PartialEq + Eq, { - fn from(type_map_opt: TypeMapOpt>) -> Self { + fn from(type_map_opt: TypeMapOpt>) -> Self { Self(type_map_opt) } } diff --git a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs index 0e776cce6..f81310299 100644 --- a/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/apply_exec_cmd_block.rs @@ -326,7 +326,7 @@ where ( States, States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -349,7 +349,7 @@ where fn outcome_collate( states_applied_mut: &mut StatesMut, states_target_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemApplyOutcome<::AppError>, ) -> Result<(), ::AppError> { let apply_for = StatesTs::apply_for(); @@ -591,18 +591,18 @@ pub enum ItemApplyOutcome { /// Error occurred when discovering current state, goal states, state /// diff, or `ApplyCheck`. PrepareFail { - item_id: ItemIdT, + item_id: ItemId, item_apply_partial: ItemApplyPartialBoxed, error: E, }, /// Ensure execution succeeded. Success { - item_id: ItemIdT, + item_id: ItemId, item_apply: ItemApplyBoxed, }, /// Ensure execution failed. Fail { - item_id: ItemIdT, + item_id: ItemId, item_apply: ItemApplyBoxed, error: E, }, diff --git a/crate/rt/src/cmd_blocks/diff_cmd_block.rs b/crate/rt/src/cmd_blocks/diff_cmd_block.rs index c6e656a9f..7c551b57b 100644 --- a/crate/rt/src/cmd_blocks/diff_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/diff_cmd_block.rs @@ -67,8 +67,8 @@ where flow: &Flow<::AppError>, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, ::AppError> { let stream_outcome_result = flow .graph() diff --git a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs index 0c399b29c..93ebb1751 100644 --- a/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_current_read_cmd_block.rs @@ -41,7 +41,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, ) -> Result::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); diff --git a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs index 3a4703f8b..5d44ad563 100644 --- a/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_discover_cmd_block.rs @@ -221,7 +221,7 @@ where &Result, ::AppError>, >, progress_tx: &Sender, - item_id: &ItemIdT, + item_id: &ItemId, ) { if let Some((progress_update, msg_update)) = DiscoverFor::progress_update( progress_complete_on_success, @@ -244,13 +244,13 @@ where pub enum ItemDiscoverOutcome { /// Discover succeeded. Success { - item_id: ItemIdT, + item_id: ItemId, state_current: Option, state_goal: Option, }, /// Discover failed. Fail { - item_id: ItemIdT, + item_id: ItemId, state_current: Option, state_goal: Option, error: AppErrorT, @@ -353,7 +353,7 @@ where ) -> Result< ( States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -369,7 +369,7 @@ where fn outcome_collate( states_current_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemDiscoverOutcome<::AppError>, ) -> Result<(), ::AppError> { match outcome_partial { @@ -496,7 +496,7 @@ where ) -> Result< ( States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -512,7 +512,7 @@ where fn outcome_collate( states_goal_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemDiscoverOutcome<::AppError>, ) -> Result<(), ::AppError> { match outcome_partial { @@ -656,7 +656,7 @@ where ( States, States, - IndexMap::AppError>, + IndexMap::AppError>, ), ::AppError, > { @@ -679,7 +679,7 @@ where fn outcome_collate( states_current_mut: &mut StatesMut, states_goal_mut: &mut StatesMut, - errors: &mut IndexMap::AppError>, + errors: &mut IndexMap::AppError>, outcome_partial: ItemDiscoverOutcome<::AppError>, ) -> Result<(), ::AppError> { match outcome_partial { diff --git a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs index bbd6cad9d..8086ca396 100644 --- a/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs +++ b/crate/rt/src/cmd_blocks/states_goal_read_cmd_block.rs @@ -41,7 +41,7 @@ where pub(crate) async fn deserialize_internal( resources: &mut Resources, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, ) -> Result::AppError> { let flow_id = resources.borrow::(); let flow_dir = resources.borrow::(); diff --git a/crate/rt/src/cmds/diff_cmd.rs b/crate/rt/src/cmds/diff_cmd.rs index e4697973f..e1171864d 100644 --- a/crate/rt/src/cmds/diff_cmd.rs +++ b/crate/rt/src/cmds/diff_cmd.rs @@ -1,7 +1,7 @@ use std::{fmt::Debug, marker::PhantomData}; use futures::{StreamExt, TryStreamExt}; -use peace_cfg::{ItemIdT, Profile}; +use peace_cfg::{ItemId, Profile}; use peace_cmd::{ ctx::{CmdCtx, CmdCtxTypesConstrained}, scopes::{MultiProfileSingleFlow, MultiProfileSingleFlowView, SingleProfileSingleFlow}, @@ -221,8 +221,8 @@ where flow: &Flow<::AppError>, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result::AppError> { let state_diffs = { let state_diffs_mut = flow diff --git a/crate/rt_model/src/item_rt.rs b/crate/rt_model/src/item_rt.rs index 294d29d33..561fe5532 100644 --- a/crate/rt_model/src/item_rt.rs +++ b/crate/rt_model/src/item_rt.rs @@ -156,8 +156,8 @@ pub trait ItemRt: &self, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, E> where E: Debug + std::error::Error; diff --git a/crate/rt_model/src/item_wrapper.rs b/crate/rt_model/src/item_wrapper.rs index d623e1a7b..5d617277d 100644 --- a/crate/rt_model/src/item_wrapper.rs +++ b/crate/rt_model/src/item_wrapper.rs @@ -243,8 +243,8 @@ where &self, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, E> { let item_id = ::id(self); let state_base = states_a.get::(item_id); @@ -666,8 +666,8 @@ where &self, params_specs: &ParamsSpecs, resources: &Resources, - states_a: &TypeMap, - states_b: &TypeMap, + states_a: &TypeMap, + states_b: &TypeMap, ) -> Result, E> { self.state_diff_exec(params_specs, resources, states_a, states_b) .await diff --git a/crate/rt_model/src/params_specs_type_reg.rs b/crate/rt_model/src/params_specs_type_reg.rs index b2992ab2b..612e10fa3 100644 --- a/crate/rt_model/src/params_specs_type_reg.rs +++ b/crate/rt_model/src/params_specs_type_reg.rs @@ -16,7 +16,7 @@ use peace_resources::type_reg::untagged::TypeReg; /// [`Params`]: peace_cfg::Item::Params /// [`StatesTypeReg`]: crate::StatesTypeReg #[derive(Debug, Default)] -pub struct ParamsSpecsTypeReg(TypeReg); +pub struct ParamsSpecsTypeReg(TypeReg); impl ParamsSpecsTypeReg { /// Returns a new `ParamsSpecsTypeReg`. @@ -26,7 +26,7 @@ impl ParamsSpecsTypeReg { } impl Deref for ParamsSpecsTypeReg { - type Target = TypeReg; + type Target = TypeReg; fn deref(&self) -> &Self::Target { &self.0 diff --git a/crate/rt_model/src/states_serializer.rs b/crate/rt_model/src/states_serializer.rs index b4e03a6cf..5ccc44f2f 100644 --- a/crate/rt_model/src/states_serializer.rs +++ b/crate/rt_model/src/states_serializer.rs @@ -67,7 +67,7 @@ where pub async fn deserialize_stored( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, ) -> Result { let states = Self::deserialize_internal::( @@ -96,7 +96,7 @@ where pub async fn deserialize_goal( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_goal_file: &StatesGoalFile, ) -> Result { let states = Self::deserialize_internal::( @@ -126,7 +126,7 @@ where pub async fn deserialize_stored_opt( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_current_file: &StatesCurrentFile, ) -> Result, E> { Self::deserialize_internal( @@ -162,7 +162,7 @@ where thread_name: String, flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_file_path: &Path, ) -> Result>, E> where @@ -229,7 +229,7 @@ where async fn deserialize_internal( flow_id: &FlowId, storage: &Storage, - states_type_reg: &TypeReg, + states_type_reg: &TypeReg, states_file_path: &Path, ) -> Result>, E> where diff --git a/crate/rt_model/src/states_type_reg.rs b/crate/rt_model/src/states_type_reg.rs index 073b30d7b..aeda73d79 100644 --- a/crate/rt_model/src/states_type_reg.rs +++ b/crate/rt_model/src/states_type_reg.rs @@ -17,7 +17,7 @@ use peace_resources::type_reg::untagged::{BoxDtDisplay, TypeReg}; /// [`StatesGoalFile`]: peace_resources::paths::StatesGoalFile /// [`StatesCurrentFile`]: peace_resources::paths::StatesCurrentFile #[derive(Debug, Default)] -pub struct StatesTypeReg(TypeReg); +pub struct StatesTypeReg(TypeReg); impl StatesTypeReg { /// Returns new `StatesTypeReg`. @@ -27,7 +27,7 @@ impl StatesTypeReg { } impl Deref for StatesTypeReg { - type Target = TypeReg; + type Target = TypeReg; fn deref(&self) -> &Self::Target { &self.0 diff --git a/crate/rt_model_core/src/cmd_progress_tracker.rs b/crate/rt_model_core/src/cmd_progress_tracker.rs index 7f45b0a0a..09f78e6f6 100644 --- a/crate/rt_model_core/src/cmd_progress_tracker.rs +++ b/crate/rt_model_core/src/cmd_progress_tracker.rs @@ -18,14 +18,14 @@ pub struct CmdProgressTracker { /// `MultiProgress` that tracks the remaining progress bars. pub multi_progress: MultiProgress, /// Tracks progress for each item. - pub progress_trackers: IndexMap, + pub progress_trackers: IndexMap, } impl CmdProgressTracker { /// Returns a new `CmdProgressTracker`. pub fn new( multi_progress: MultiProgress, - progress_trackers: IndexMap, + progress_trackers: IndexMap, ) -> Self { Self { multi_progress, @@ -45,13 +45,13 @@ impl CmdProgressTracker { } /// Returns the `ProgressTracker`s for each item. - pub fn progress_trackers(&self) -> &IndexMap { + pub fn progress_trackers(&self) -> &IndexMap { &self.progress_trackers } /// Returns a mutable reference to the `ProgressTracker`s for each item /// spec. - pub fn progress_trackers_mut(&mut self) -> &mut IndexMap { + pub fn progress_trackers_mut(&mut self) -> &mut IndexMap { &mut self.progress_trackers } } diff --git a/crate/rt_model_core/src/error.rs b/crate/rt_model_core/src/error.rs index 3acf722ad..4f9561d9f 100644 --- a/crate/rt_model_core/src/error.rs +++ b/crate/rt_model_core/src/error.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use peace_cmd_model::CmdExecutionError; -use peace_core::{FlowId, ItemIdT, Profile}; +use peace_core::{FlowId, ItemId, Profile}; use peace_params::{ParamsResolveError, ParamsSpecs}; use peace_resources::paths::ParamsSpecsFile; @@ -102,7 +102,7 @@ pub enum Error { )] ParamsSpecNotFound { /// Item ID for which the params spec was not found. - item_id: ItemIdT, + item_id: ItemId, }, /// Item params specs do not match with the items in the flow. diff --git a/crate/rt_model_core/src/items_state_stored_stale.rs b/crate/rt_model_core/src/items_state_stored_stale.rs index 6f0c7225c..9111f376e 100644 --- a/crate/rt_model_core/src/items_state_stored_stale.rs +++ b/crate/rt_model_core/src/items_state_stored_stale.rs @@ -7,11 +7,11 @@ use crate::StateStoredAndDiscovered; /// Items whose stored and discovered state are not equal. /// -/// `IndexMap` newtype. +/// `IndexMap` newtype. /// /// This can be used for either current state or goal state. #[derive(Clone, Debug, Default)] -pub struct ItemsStateStoredStale(IndexMap); +pub struct ItemsStateStoredStale(IndexMap); impl ItemsStateStoredStale { /// Returns a new `ItemsStateStoredStale` map. @@ -26,7 +26,7 @@ impl ItemsStateStoredStale { } /// Returns the underlying map. - pub fn into_inner(self) -> IndexMap { + pub fn into_inner(self) -> IndexMap { self.0 } @@ -37,7 +37,7 @@ impl ItemsStateStoredStale { } impl Deref for ItemsStateStoredStale { - type Target = IndexMap; + type Target = IndexMap; fn deref(&self) -> &Self::Target { &self.0 @@ -50,8 +50,8 @@ impl DerefMut for ItemsStateStoredStale { } } -impl FromIterator<(ItemIdT, StateStoredAndDiscovered)> for ItemsStateStoredStale { - fn from_iter>(iter: I) -> Self { +impl FromIterator<(ItemId, StateStoredAndDiscovered)> for ItemsStateStoredStale { + fn from_iter>(iter: I) -> Self { Self(IndexMap::from_iter(iter)) } } diff --git a/examples/download/src/lib.rs b/examples/download/src/lib.rs index 5f185f4c7..ac50cc643 100644 --- a/examples/download/src/lib.rs +++ b/examples/download/src/lib.rs @@ -1,5 +1,5 @@ use peace::{ - cfg::{app_name, item_id, FlowId, ItemIdT, Profile}, + cfg::{app_name, item_id, FlowId, ItemId, Profile}, cmd::{ctx::CmdCtx, scopes::SingleProfileSingleFlow}, cmd_model::CmdOutcome, rt::cmds::{ diff --git a/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs b/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs index 26f8e6048..147b98da8 100644 --- a/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs +++ b/examples/envman/src/items/peace_aws_iam_policy/iam_policy_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_iam_policy::{ #[derive(Debug)] pub struct IamPolicyItem { /// ID of the instance profile item. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique instance profile parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs b/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs index e03a3f1bb..976bcfab7 100644 --- a/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs +++ b/examples/envman/src/items/peace_aws_iam_role/iam_role_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_iam_role::{ #[derive(Debug)] pub struct IamRoleItem { /// ID of the instance profile item. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique instance profile parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs b/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs index c9ae9551d..5f03ab917 100644 --- a/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs +++ b/examples/envman/src/items/peace_aws_instance_profile/instance_profile_item.rs @@ -31,7 +31,7 @@ use crate::items::peace_aws_instance_profile::{ #[derive(Debug)] pub struct InstanceProfileItem { /// ID of the instance profile item. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique instance profile parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs b/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs index 1e7c2df90..337a05fea 100644 --- a/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs +++ b/examples/envman/src/items/peace_aws_s3_bucket/s3_bucket_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_s3_bucket::{ #[derive(Debug)] pub struct S3BucketItem { /// ID of the S3 bucket item. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique S3 bucket parameters type. marker: PhantomData, } diff --git a/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs b/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs index 4b01145c4..66a41ae4b 100644 --- a/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs +++ b/examples/envman/src/items/peace_aws_s3_object/s3_object_item.rs @@ -30,7 +30,7 @@ use crate::items::peace_aws_s3_object::{ #[derive(Debug)] pub struct S3ObjectItem { /// ID of the S3 object item. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique S3 object parameters type. marker: PhantomData, } diff --git a/examples/envman/src/output.rs b/examples/envman/src/output.rs index 84259a349..275ffc729 100644 --- a/examples/envman/src/output.rs +++ b/examples/envman/src/output.rs @@ -1,5 +1,5 @@ use peace::{ - cfg::ItemIdT, + cfg::ItemId, cmd_model::CmdOutcome, fmt::{ presentable::{Heading, HeadingLevel}, @@ -67,7 +67,7 @@ where /// Presents item errors. pub async fn item_errors_present( output: &mut O, - errors: &IndexMap, + errors: &IndexMap, ) -> Result<(), EnvManError> where O: OutputWrite, diff --git a/examples/envman/src/web/flow_dot_renderer.rs b/examples/envman/src/web/flow_dot_renderer.rs index 58765cc96..6e746f0c8 100644 --- a/examples/envman/src/web/flow_dot_renderer.rs +++ b/examples/envman/src/web/flow_dot_renderer.rs @@ -1,4 +1,4 @@ -use peace::{cfg::ItemIdT, rt_model::Flow}; +use peace::{cfg::ItemId, rt_model::Flow}; /// Renders a `Flow` as a GraphViz Dot diagram. /// @@ -157,7 +157,7 @@ impl FlowDotRenderer { ) } - fn edge(&self, src_item_id: &ItemIdT, target_item_id: &ItemId) -> String { + fn edge(&self, src_item_id: &ItemId, target_item_id: &ItemId) -> String { format!(r#"{src_item_id} -> {target_item_id} [minlen = 9]"#) } } diff --git a/items/blank/src/blank_item.rs b/items/blank/src/blank_item.rs index 29df5684d..27d545860 100644 --- a/items/blank/src/blank_item.rs +++ b/items/blank/src/blank_item.rs @@ -20,7 +20,7 @@ use crate::{BlankApplyFns, BlankData, BlankError, BlankParams, BlankState, Blank #[derive(Debug)] pub struct BlankItem { /// ID of the blank item. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique blank parameters type. marker: PhantomData, } diff --git a/items/file_download/src/file_download_item.rs b/items/file_download/src/file_download_item.rs index 57b21f3ab..111fa97d1 100644 --- a/items/file_download/src/file_download_item.rs +++ b/items/file_download/src/file_download_item.rs @@ -1,7 +1,7 @@ use std::{marker::PhantomData, path::Path}; use peace::{ - cfg::{async_trait, state::FetchedOpt, ApplyCheck, FnCtx, Item, ItemIdT, State}, + cfg::{async_trait, state::FetchedOpt, ApplyCheck, FnCtx, Item, ItemId, State}, params::Params, resources::{resources::ts::Empty, Resources}, }; @@ -24,7 +24,7 @@ use crate::{ #[derive(Debug)] pub struct FileDownloadItem { /// ID of the item to download the file. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique download parameters type. marker: PhantomData, } diff --git a/items/sh_cmd/src/sh_cmd_item.rs b/items/sh_cmd/src/sh_cmd_item.rs index 2fa1a66d1..30dd86e04 100644 --- a/items/sh_cmd/src/sh_cmd_item.rs +++ b/items/sh_cmd/src/sh_cmd_item.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use peace::{ - cfg::{async_trait, ApplyCheck, FnCtx, Item, ItemIdT, State}, + cfg::{async_trait, ApplyCheck, FnCtx, Item, ItemId, State}, params::Params, resources::{resources::ts::Empty, Resources}, }; @@ -23,7 +23,7 @@ use crate::{ #[derive(Debug)] pub struct ShCmdItem { /// ID to easily tell what the item command is for. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique command execution parameters type. marker: PhantomData, } diff --git a/items/tar_x/src/tar_x_item.rs b/items/tar_x/src/tar_x_item.rs index c5214d1a7..6097e10ba 100644 --- a/items/tar_x/src/tar_x_item.rs +++ b/items/tar_x/src/tar_x_item.rs @@ -29,7 +29,7 @@ use crate::{ #[derive(Debug)] pub struct TarXItem { /// ID of the item to extract the tar. - item_id: ItemIdT, + item_id: ItemId, /// Marker for unique tar extraction parameters type. marker: PhantomData, } diff --git a/workspace_tests/src/cfg/item_id.rs b/workspace_tests/src/cfg/item_id.rs index 6da09787a..c94fc5945 100644 --- a/workspace_tests/src/cfg/item_id.rs +++ b/workspace_tests/src/cfg/item_id.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, str::FromStr}; use peace::{ - cfg::{ItemIdInvalidFmt, ItemIdT}, + cfg::{ItemId, ItemIdInvalidFmt}, fmt::Presentable, }; diff --git a/workspace_tests/src/items/sh_cmd_item.rs b/workspace_tests/src/items/sh_cmd_item.rs index d9aa2a4e5..20c120f65 100644 --- a/workspace_tests/src/items/sh_cmd_item.rs +++ b/workspace_tests/src/items/sh_cmd_item.rs @@ -1,5 +1,5 @@ use peace::{ - cfg::{app_name, item_id, profile, FlowId, ItemIdT, State}, + cfg::{app_name, item_id, profile, FlowId, ItemId, State}, cmd::ctx::CmdCtx, cmd_model::CmdOutcome, data::marker::Clean, diff --git a/workspace_tests/src/items/tar_x_item.rs b/workspace_tests/src/items/tar_x_item.rs index fa83a1582..8a1444b70 100644 --- a/workspace_tests/src/items/tar_x_item.rs +++ b/workspace_tests/src/items/tar_x_item.rs @@ -1,7 +1,7 @@ use std::{io::Cursor, path::PathBuf}; use peace::{ - cfg::{app_name, item_id, profile, ApplyCheck, FlowId, Item, ItemIdT, Profile}, + cfg::{app_name, item_id, profile, ApplyCheck, FlowId, Item, ItemId, Profile}, cmd::{ctx::CmdCtx, scopes::SingleProfileSingleFlowView}, cmd_model::CmdOutcome, data::Data, diff --git a/workspace_tests/src/mock_item.rs b/workspace_tests/src/mock_item.rs index 3d2967d97..2644b9828 100644 --- a/workspace_tests/src/mock_item.rs +++ b/workspace_tests/src/mock_item.rs @@ -27,7 +27,7 @@ where Id: Clone + Debug + Default + Send + Sync + 'static, { /// ID of the item. - id: ItemIdT, + id: ItemId, /// Marker. mock_fns: MockFns, } diff --git a/workspace_tests/src/rt/cmds/states_discover_cmd.rs b/workspace_tests/src/rt/cmds/states_discover_cmd.rs index 7faf068ce..e04fe7c06 100644 --- a/workspace_tests/src/rt/cmds/states_discover_cmd.rs +++ b/workspace_tests/src/rt/cmds/states_discover_cmd.rs @@ -736,7 +736,7 @@ async fn goal_runs_state_goal_for_each_item() -> Result<(), Box(); let states_slice = std::fs::read(&*states_goal_file)?; - let mut type_reg = TypeReg::::new_typed(); + let mut type_reg = TypeReg::::new_typed(); type_reg.register::(VecCopyItem::ID_DEFAULT.clone()); let deserializer = serde_yaml::Deserializer::from_slice(&states_slice); diff --git a/workspace_tests/src/vec_copy_item.rs b/workspace_tests/src/vec_copy_item.rs index 6bf943378..62e1c0583 100644 --- a/workspace_tests/src/vec_copy_item.rs +++ b/workspace_tests/src/vec_copy_item.rs @@ -25,7 +25,7 @@ pub type VecCopyItemWrapper = ItemWrapper; #[derive(Clone, Debug)] pub struct VecCopyItem { /// ID of the item. - id: ItemIdT, + id: ItemId, } impl VecCopyItem { From 9255e0c7914ae4fa6254c898d524e8e323b21b62 Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Thu, 1 Feb 2024 18:32:02 +1300 Subject: [PATCH 6/7] Revert "Change `ItemId` struct into a trait." This reverts commit bc2bb6b4962b5b9e3e37c420b7d5dbee856f9487. --- crate/core/src/item_id.rs | 63 +++++++++------------------------------ crate/core/src/lib.rs | 2 +- 2 files changed, 15 insertions(+), 50 deletions(-) diff --git a/crate/core/src/item_id.rs b/crate/core/src/item_id.rs index ef78421b4..e457b1ff7 100644 --- a/crate/core/src/item_id.rs +++ b/crate/core/src/item_id.rs @@ -1,59 +1,24 @@ -use std::{fmt::Debug, hash::Hash}; +use std::borrow::Cow; -use serde::{de::Deserialize, Serialize}; +use serde::{Deserialize, Serialize}; -/// Unique identifier for an `Item`. +/// Unique identifier for an `ItemId`, `Cow<'static, str>` newtype. /// -/// This is a flat enum, where each variant represents an item managed by the -/// automation software. +/// Must begin with a letter or underscore, and contain only letters, numbers, +/// and underscores. /// /// # Examples /// -/// The following +/// The following are all examples of valid `ItemId`s: /// /// ```rust -/// use peace_core::ItemId; -/// use serde::{Deserialize, Serialize}; -/// -/// #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)] -/// #[serde(rename_all = "snake_case")] -/// pub enum EnvmanItemId { -/// AppDownload, -/// AppExtract, -/// IamPolicy, -/// IamRole, -/// InstanceProfile, -/// S3Bucket, -/// S3Object, -/// } +/// # use peace_core::{item_id, ItemId}; +/// # +/// let _snake = item_id!("snake_case"); +/// let _camel = item_id!("camelCase"); +/// let _pascal = item_id!("PascalCase"); /// ``` -/// -/// # Design Note -/// -/// TODO: Experiment with upgrades. -/// -/// For compatibility and migrating item IDs deployed with old versions of -/// the automation software, experiment with the following: -/// -/// * developers should provide a `#[serde(from = "FromType")]` implementation, -/// where the `FromType` contains the `ItemId`s from previous automation -/// software versions. -/// * the `ItemId` implementation is a hierarchical enum, with a variant for -/// each version of the automation software's items. -pub trait ItemId: - Clone + Copy + Debug + Hash + PartialEq + Eq + for<'de> Deserialize<'de> + Serialize + 'static -{ -} +#[derive(Clone, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)] +pub struct ItemId(Cow<'static, str>); -impl ItemId for T where - T: Clone - + Copy - + Debug - + Hash - + PartialEq - + Eq - + for<'de> Deserialize<'de> - + Serialize - + 'static -{ -} +crate::id_newtype!(ItemId, ItemIdInvalidFmt, item_id, code_inline); diff --git a/crate/core/src/lib.rs b/crate/core/src/lib.rs index 565f70de9..333f07cfa 100644 --- a/crate/core/src/lib.rs +++ b/crate/core/src/lib.rs @@ -19,7 +19,7 @@ pub use crate::{ app_name::{AppName, AppNameInvalidFmt}, apply_check::ApplyCheck, flow_id::{FlowId, FlowIdInvalidFmt}, - item_id::ItemId, + item_id::{ItemId, ItemIdInvalidFmt}, profile::{Profile, ProfileInvalidFmt}, }; From 8edea31daf23daba1020d09ef6c59c264e60488f Mon Sep 17 00:00:00 2001 From: Azriel Hoh Date: Thu, 1 Feb 2024 18:40:03 +1300 Subject: [PATCH 7/7] Add design note about upgrades for `ItemId`s. --- crate/core/src/item_id.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crate/core/src/item_id.rs b/crate/core/src/item_id.rs index e457b1ff7..43d2c7466 100644 --- a/crate/core/src/item_id.rs +++ b/crate/core/src/item_id.rs @@ -18,6 +18,18 @@ use serde::{Deserialize, Serialize}; /// let _camel = item_id!("camelCase"); /// let _pascal = item_id!("PascalCase"); /// ``` +/// +/// # Design Note +/// +/// TODO: Experiment with upgrades. +/// +/// For backward compatibility and migrating items from old IDs to new IDs, e.g. +/// when they were deployed with an old version of the automation software, +/// there needs to be a way to: +/// +/// * Read state using the old ID. +/// * Either clean up that state, or migrate that state into an Item with the +/// new ID. #[derive(Clone, Debug, Hash, PartialEq, Eq, Deserialize, Serialize)] pub struct ItemId(Cow<'static, str>);