(&self, key: String)
| 188 | |
| 189 | #[tracing::instrument(level = "debug", skip(self, key))] |
| 190 | pub fn load_selective_array<T>(&self, key: String) -> Result<T> |
| 191 | where |
| 192 | T: DeserializeOwned, |
| 193 | { |
| 194 | tracing::debug!("Loading selective array {}", key); |
| 195 | let mut split: Vec<&str> = key.split('.').collect(); |
| 196 | let child = split.pop().unwrap(); |
| 197 | let parent = split.join("."); |
| 198 | |
| 199 | let mut preference: Value = self.load_selective(parent.to_string())?; |
| 200 | if preference.is_array() { |
| 201 | for item in preference.as_array_mut().unwrap() { |
| 202 | if let Some(key) = item.get("key") { |
| 203 | if key == child { |
| 204 | return Ok(serde_json::from_value((*item).take())?); |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | Err(MoosyncError::String("Value is not an array".into())) |
| 211 | } |
| 212 | |
| 213 | #[tracing::instrument(level = "debug", skip(self, key))] |
| 214 | pub fn get_secure<T>(&self, key: String) -> Result<T> |
no test coverage detected