@@ -11,20 +11,21 @@ pub trait SetupOperator: 'static + Send + Sync {
1111 type Key : Debug + Hash + Eq + Clone + Send + Sync ;
1212 type State : State < Self :: Key > ;
1313 type SetupState : Send + Sync + IntoIterator < Item = Self :: State > ;
14+ type Context : Sync ;
1415
1516 fn describe_key ( & self , key : & Self :: Key ) -> String ;
1617
1718 fn describe_state ( & self , state : & Self :: State ) -> String ;
1819
1920 fn is_up_to_date ( & self , current : & Self :: State , desired : & Self :: State ) -> bool ;
2021
21- async fn create ( & self , state : & Self :: State ) -> Result < ( ) > ;
22+ async fn create ( & self , state : & Self :: State , context : & Self :: Context ) -> Result < ( ) > ;
2223
23- async fn delete ( & self , key : & Self :: Key ) -> Result < ( ) > ;
24+ async fn delete ( & self , key : & Self :: Key , context : & Self :: Context ) -> Result < ( ) > ;
2425
25- async fn update ( & self , state : & Self :: State ) -> Result < ( ) > {
26- self . delete ( & state. key ( ) ) . await ?;
27- self . create ( state) . await
26+ async fn update ( & self , state : & Self :: State , context : & Self :: Context ) -> Result < ( ) > {
27+ self . delete ( & state. key ( ) , context ) . await ?;
28+ self . create ( state, context ) . await
2829 }
2930}
3031
@@ -150,21 +151,22 @@ impl<D: SetupOperator + Send + Sync> ResourceSetupStatus for SetupStatus<D> {
150151
151152pub async fn apply_component_changes < D : SetupOperator > (
152153 changes : Vec < & SetupStatus < D > > ,
154+ context : & D :: Context ,
153155) -> Result < ( ) > {
154156 // First delete components that need to be removed
155157 for change in changes. iter ( ) {
156158 for key in & change. keys_to_delete {
157- change. desc . delete ( key) . await ?;
159+ change. desc . delete ( key, context ) . await ?;
158160 }
159161 }
160162
161163 // Then upsert components that need to be updated
162164 for change in changes. iter ( ) {
163165 for state in & change. states_to_upsert {
164166 if state. already_exists {
165- change. desc . update ( & state. state ) . await ?;
167+ change. desc . update ( & state. state , context ) . await ?;
166168 } else {
167- change. desc . create ( & state. state ) . await ?;
169+ change. desc . create ( & state. state , context ) . await ?;
168170 }
169171 }
170172 }
0 commit comments