mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
PPT restor defaults (WIP)
This commit is contained in:
@@ -76,11 +76,11 @@ impl Attribute {
|
||||
}
|
||||
|
||||
/// Write the `current_value` directly to the attribute path
|
||||
pub fn set_current_value(&self, new_value: AttrValue) -> Result<(), PlatformError> {
|
||||
pub fn set_current_value(&self, new_value: &AttrValue) -> Result<(), PlatformError> {
|
||||
let path = self.base_path.join("current_value");
|
||||
|
||||
let value_str = match new_value {
|
||||
AttrValue::Integer(val) => val.to_string(),
|
||||
AttrValue::Integer(val) => &val.to_string(),
|
||||
AttrValue::String(val) => val,
|
||||
_ => return Err(PlatformError::InvalidValue)
|
||||
};
|
||||
@@ -94,6 +94,10 @@ impl Attribute {
|
||||
&self.default_value
|
||||
}
|
||||
|
||||
pub fn restore_default(&self) -> Result<(), PlatformError> {
|
||||
self.set_current_value(&self.default_value)
|
||||
}
|
||||
|
||||
pub fn possible_values(&self) -> &AttrValue {
|
||||
&self.possible_values
|
||||
}
|
||||
@@ -453,6 +457,6 @@ mod tests {
|
||||
if let AttrValue::Integer(val) = &mut val {
|
||||
*val = 0;
|
||||
}
|
||||
attr.set_current_value(val).unwrap();
|
||||
attr.set_current_value(&val).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user