(
&self,
cache_key: &str,
measurements: &TdxMeasurements,
)
| 209 | } |
| 210 | |
| 211 | fn store_measurements_in_cache( |
| 212 | &self, |
| 213 | cache_key: &str, |
| 214 | measurements: &TdxMeasurements, |
| 215 | ) -> Result<()> { |
| 216 | let cache_dir = self.measurement_cache_dir(); |
| 217 | fs_err::create_dir_all(&cache_dir) |
| 218 | .context("Failed to create measurement cache directory")?; |
| 219 | |
| 220 | let path = self.measurement_cache_path(cache_key); |
| 221 | let mut tmp = tempfile::NamedTempFile::new_in(&cache_dir) |
| 222 | .context("Failed to create temporary cache file")?; |
| 223 | |
| 224 | let entry = CachedMeasurement { |
| 225 | version: MEASUREMENT_CACHE_VERSION, |
| 226 | measurements: measurements.clone(), |
| 227 | }; |
| 228 | serde_json::to_writer(tmp.as_file_mut(), &entry) |
| 229 | .context("Failed to serialize measurement cache entry")?; |
| 230 | tmp.as_file_mut() |
| 231 | .sync_all() |
| 232 | .context("Failed to flush measurement cache entry to disk")?; |
| 233 | |
| 234 | tmp.persist(&path).map_err(|e| { |
| 235 | anyhow!( |
| 236 | "Failed to persist measurement cache to {}: {e}", |
| 237 | path.display() |
| 238 | ) |
| 239 | })?; |
| 240 | debug!("Stored measurement cache entry {}", cache_key); |
| 241 | Ok(()) |
| 242 | } |
| 243 | |
| 244 | fn compute_measurement_details( |
| 245 | &self, |
no test coverage detected