MCPcopy Create free account
hub / github.com/PowerShell/DSC / test_key

Function test_key

archive/registry/src/regconfighelper.rs:314–346  ·  view source on GitHub ↗
(config: &Registry)

Source from the content-addressed store, hash-verified

312}
313
314fn 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
348fn convert_ntreg_data(reg_data: &NtRegistryValueData) -> Result<RegistryValueData, RegistryError> {
349 match reg_data {

Callers 1

config_testFunction · 0.85

Calls 4

as_strMethod · 0.80
defaultFunction · 0.50
newFunction · 0.50
to_jsonMethod · 0.45

Tested by

no test coverage detected