@@ -17,6 +17,7 @@ use indenter::indented;
1717use std:: fmt:: Debug ;
1818use std:: fmt:: { Display , Write } ;
1919use std:: hash:: Hash ;
20+ use std:: marker:: PhantomData ;
2021
2122use super :: db_metadata;
2223use crate :: execution:: db_tracking_setup;
@@ -214,15 +215,16 @@ pub enum SetupChangeType {
214215}
215216
216217#[ async_trait]
217- pub trait ResourceSetupStatusCheck : Debug + Send + Sync {
218- type Key : Debug + Clone + Serialize + DeserializeOwned + Eq + Hash ;
219- type State : Debug + Clone + Serialize + DeserializeOwned ;
220-
218+ pub trait ResourceSetupStatusCheck < K , S > : Debug + Send + Sync
219+ where
220+ K : Debug + Clone + Serialize + DeserializeOwned + Eq + Hash ,
221+ S : Debug + Clone + Serialize + DeserializeOwned ,
222+ {
221223 fn describe_resource ( & self ) -> String ;
222224
223- fn key ( & self ) -> & Self :: Key ;
225+ fn key ( & self ) -> & K ;
224226
225- fn desired_state ( & self ) -> Option < & Self :: State > ;
227+ fn desired_state ( & self ) -> Option < & S > ;
226228
227229 fn describe_changes ( & self ) -> Vec < String > ;
228230
@@ -233,6 +235,37 @@ pub trait ResourceSetupStatusCheck: Debug + Send + Sync {
233235 }
234236}
235237
238+ #[ async_trait]
239+ impl < K , S > ResourceSetupStatusCheck < K , S > for std:: convert:: Infallible
240+ where
241+ K : Debug + Clone + Serialize + DeserializeOwned + Eq + Hash ,
242+ S : Debug + Clone + Serialize + DeserializeOwned ,
243+ {
244+ fn describe_resource ( & self ) -> String {
245+ unreachable ! ( )
246+ }
247+
248+ fn key ( & self ) -> & K {
249+ unreachable ! ( )
250+ }
251+
252+ fn desired_state ( & self ) -> Option < & S > {
253+ unreachable ! ( )
254+ }
255+
256+ fn describe_changes ( & self ) -> Vec < String > {
257+ unreachable ! ( )
258+ }
259+
260+ fn change_type ( & self ) -> SetupChangeType {
261+ unreachable ! ( )
262+ }
263+
264+ async fn apply_change ( & self ) -> Result < ( ) > {
265+ unreachable ! ( )
266+ }
267+ }
268+
236269#[ derive( Debug , Clone , Copy , Serialize , Deserialize , PartialEq , Eq ) ]
237270pub enum ObjectStatus {
238271 Invalid ,
@@ -248,18 +281,17 @@ pub trait ObjectSetupStatusCheck {
248281
249282#[ derive( Debug ) ]
250283pub struct TargetResourceSetupStatusCheck {
251- pub target_kind : String ,
252- pub common : Option < TargetSetupStateCommon > ,
253- pub status_check : Box <
254- dyn ResourceSetupStatusCheck < Key = serde_json:: Value , State = serde_json:: Value >
255- + Send
256- + Sync ,
257- > ,
284+ pub status_check :
285+ Box < dyn ResourceSetupStatusCheck < serde_json:: Value , serde_json:: Value > + Send + Sync > ,
258286}
259287
260288impl std:: fmt:: Display for TargetResourceSetupStatusCheck {
261289 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
262- write ! ( f, "{}" , FormattedResourceSetup ( self . status_check. as_ref( ) ) )
290+ write ! (
291+ f,
292+ "{}" ,
293+ FormattedResourceSetup ( self . status_check. as_ref( ) , PhantomData :: default ( ) )
294+ )
263295 }
264296}
265297
@@ -326,10 +358,18 @@ impl<StatusCheck: ObjectSetupStatusCheck> std::fmt::Display
326358 }
327359}
328360
329- pub struct FormattedResourceSetup < ' a , Check : ResourceSetupStatusCheck + ?Sized > ( & ' a Check ) ;
361+ pub struct FormattedResourceSetup <
362+ ' a ,
363+ K : Debug + Clone + Serialize + DeserializeOwned + Eq + Hash ,
364+ S : Debug + Clone + Serialize + DeserializeOwned ,
365+ Check : ResourceSetupStatusCheck < K , S > + ?Sized ,
366+ > ( & ' a Check , PhantomData < ( K , S ) > ) ;
330367
331- impl < Change : ResourceSetupStatusCheck + ?Sized > std:: fmt:: Display
332- for FormattedResourceSetup < ' _ , Change >
368+ impl < K , S , Check > std:: fmt:: Display for FormattedResourceSetup < ' _ , K , S , Check >
369+ where
370+ K : Debug + Clone + Serialize + DeserializeOwned + Eq + Hash ,
371+ S : Debug + Clone + Serialize + DeserializeOwned ,
372+ Check : ResourceSetupStatusCheck < K , S > + ?Sized ,
333373{
334374 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
335375 let status_code = match self . 0 . change_type ( ) {
@@ -377,7 +417,11 @@ impl std::fmt::Display for FormattedFlowSetupStatusCheck<'_> {
377417 ) ?;
378418
379419 let mut f = indented ( f) . with_str ( INDENT ) ;
380- write ! ( f, "{}" , FormattedResourceSetup ( & flow_ssc. tracking_table) ) ?;
420+ write ! (
421+ f,
422+ "{}" ,
423+ FormattedResourceSetup ( & flow_ssc. tracking_table, PhantomData :: default ( ) )
424+ ) ?;
381425
382426 for target_resource in & flow_ssc. target_resources {
383427 writeln ! ( f, "{}" , target_resource) ?;
@@ -389,7 +433,11 @@ impl std::fmt::Display for FormattedFlowSetupStatusCheck<'_> {
389433
390434impl std:: fmt:: Display for AllSetupStatusCheck {
391435 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
392- write ! ( f, "{}" , FormattedResourceSetup ( & self . metadata_table) ) ?;
436+ write ! (
437+ f,
438+ "{}" ,
439+ FormattedResourceSetup ( & self . metadata_table, PhantomData :: default ( ) )
440+ ) ?;
393441 for ( flow_name, flow_status) in & self . flows {
394442 write ! (
395443 f,
0 commit comments