(config: &Registry)
| 312 | } |
| 313 | |
| 314 | fn test_key(config: &Registry) -> Result<String, RegistryError> { |
| 315 | let mut reg_result: Registry = Registry { key_path: config.key_path.clone(), ..Default::default()}; |
| 316 | |
| 317 | let key_exists = match RegistryKey::new(config.key_path.as_str()) { |
| 318 | Ok( _ ) => { |
| 319 | true |
| 320 | }, |
| 321 | Err(NtStatusError { status: NtStatusErrorKind::ObjectNameNotFound, ..}) => { |
| 322 | false |
| 323 | }, |
| 324 | Err(err) => { |
| 325 | return Err(RegistryError::NtStatus(err)); |
| 326 | } |
| 327 | }; |
| 328 | |
| 329 | let mut in_desired_state = true; |
| 330 | match &config.exist { |
| 331 | Some(true) | None => { |
| 332 | if !key_exists { |
| 333 | in_desired_state = false; |
| 334 | } |
| 335 | }, |
| 336 | Some(false) => { |
| 337 | if key_exists { |
| 338 | in_desired_state = false; |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | reg_result.exist = Some(key_exists); |
| 344 | reg_result.in_desired_state = Some(in_desired_state); |
| 345 | Ok(reg_result.to_json()) |
| 346 | } |
| 347 | |
| 348 | fn convert_ntreg_data(reg_data: &NtRegistryValueData) -> Result<RegistryValueData, RegistryError> { |
| 349 | match reg_data { |
no test coverage detected