(
dir: &std::path::Path,
)
| 244 | |
| 245 | #[cfg(feature = "std")] |
| 246 | pub fn try_project_config( |
| 247 | dir: &std::path::Path, |
| 248 | ) -> Option<(Result<ProjectConfig>, ProjectConfigInfo)> { |
| 249 | for filename in CONFIG_FILENAMES.iter() { |
| 250 | let config_path = dir.join(filename); |
| 251 | let Ok(file) = std::fs::File::open(&config_path) else { |
| 252 | continue; |
| 253 | }; |
| 254 | let metadata = file.metadata(); |
| 255 | if let Ok(metadata) = metadata { |
| 256 | if !metadata.is_file() { |
| 257 | continue; |
| 258 | } |
| 259 | let ts = filetime::FileTime::from_last_modification_time(&metadata); |
| 260 | let mut reader = std::io::BufReader::new(file); |
| 261 | let mut result = read_json_config(&mut reader); |
| 262 | if let Ok(config) = &result { |
| 263 | // Validate min_version if present |
| 264 | if let Err(e) = validate_min_version(config) { |
| 265 | result = Err(e); |
| 266 | } |
| 267 | } |
| 268 | return Some((result, ProjectConfigInfo { path: config_path, timestamp: Some(ts) })); |
| 269 | } |
| 270 | } |
| 271 | None |
| 272 | } |
| 273 | |
| 274 | #[cfg(feature = "std")] |
| 275 | pub fn save_project_config( |
no test coverage detected