MCPcopy Create free account
hub / github.com/Moosync/Moosync / load_selective_array

Method load_selective_array

src-tauri/preferences/src/preferences.rs:190–211  ·  view source on GitHub ↗
(&self, key: String)

Source from the content-addressed store, hash-verified

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>

Callers 1

handle_window_closeFunction · 0.80

Calls 2

load_selectiveMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected