MCPcopy Index your code
hub / github.com/RizeCrime/linuxblaster_control / apply_profile

Method apply_profile

src/lib.rs:228–255  ·  view source on GitHub ↗
(&self, path: PathBuf)

Source from the content-addressed store, hash-verified

226 }
227
228 pub fn apply_profile(&self, path: PathBuf) -> Result<(), Box<dyn Error>> {
229 // apply a profile to the features
230
231 let json = std::fs::read_to_string(&path)?;
232 let saved: BlasterXG6 = serde_json::from_str(&json)?;
233
234 for feature in &saved.features {
235 // don't write features that haven't been changed from defautl
236 if feature.value() == 0.0 {
237 continue;
238 }
239
240 // don't write sliders if their toggle is off
241 if matches!(feature.id.value_kind(), ValueKind::Ranged { .. }) {
242 if let Some(toggle_id) = feature.id.paired_toggle() {
243 if self.feature(toggle_id).value() == 0.0 {
244 continue;
245 }
246 };
247 }
248
249 self.set_feature(feature.id, Some(feature.value()))?;
250 }
251
252 info!("Applied Profile ({:?})", path);
253
254 Ok(())
255 }
256}

Callers 1

updateMethod · 0.80

Calls 4

valueMethod · 0.80
paired_toggleMethod · 0.80
featureMethod · 0.80
set_featureMethod · 0.80

Tested by

no test coverage detected