Update the state, save it to JSON, then return whatever value the update returns.
(&mut self, f: F)
| 333 | |
| 334 | /// Update the state, save it to JSON, then return whatever value the update returns. |
| 335 | fn update_state<F, T>(&mut self, f: F) -> anyhow::Result<T> |
| 336 | where |
| 337 | F: FnOnce(&mut DockerMaterializerState) -> T, |
| 338 | { |
| 339 | let value = f(&mut self.state); |
| 340 | self.save_state()?; |
| 341 | Ok(value) |
| 342 | } |
| 343 | |
| 344 | /// Write the state to a JSON file. |
| 345 | fn save_state(&self) -> anyhow::Result<()> { |