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

Method get

lib/dsc-lib-registry/src/lib.rs:91–135  ·  view source on GitHub ↗

Get from registry. # Returns `Registry` - The registry struct. # Errors `RegistryError` - The error that occurred.

(&self)

Source from the content-addressed store, hash-verified

89 ///
90 /// * `RegistryError` - The error that occurred.
91 pub fn get(&self) -> Result<Registry, RegistryError> {
92 let exist: bool;
93 let (reg_key, _subkey) = match self.open(Security::Read) {
94 Ok((reg_key, subkey)) => {
95 (reg_key, subkey)
96 },
97 Err(RegistryError::RegistryKeyNotFound(_)) => {
98 exist = false;
99 return Ok(Registry {
100 key_path: self.config.key_path.clone(),
101 exist: Some(exist),
102 ..Default::default()
103 });
104 },
105 Err(e) => return Err(e),
106 };
107
108 if let Some(value_name) = &self.config.value_name {
109 let value = match reg_key.value(value_name) {
110 Ok(value) => value,
111 Err(value::Error::NotFound(_,_)) => {
112 exist = false;
113 return Ok(Registry {
114 key_path: self.config.key_path.clone(),
115 value_name: Some(value_name.clone()),
116 exist: Some(exist),
117 ..Default::default()
118 });
119 },
120 Err(e) => return Err(RegistryError::RegistryValue(e)),
121 };
122
123 Ok(Registry {
124 key_path: self.config.key_path.clone(),
125 value_name: Some(value_name.clone()),
126 value_data: convert_reg_value(&value)?,
127 ..Default::default()
128 })
129 } else {
130 Ok(Registry {
131 key_path: self.config.key_path.clone(),
132 ..Default::default()
133 })
134 }
135 }
136
137 /// Set in registry.
138 ///

Callers 15

mainFunction · 0.45
matches_wildcardFunction · 0.45
subsystem_keywordFunction · 0.45
subsystem_single_entryFunction · 0.45
single_match_blockFunction · 0.45
multiple_match_blocksFunction · 0.45

Calls 4

RegistryValueClass · 0.85
convert_reg_valueFunction · 0.85
defaultFunction · 0.50
openMethod · 0.45