mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Embedding API: prefs r/w
This commit is contained in:
parent
7df4655b60
commit
479afcfb8e
10 changed files with 460 additions and 157 deletions
|
@ -220,6 +220,17 @@ impl<'m, P: Clone> Preferences<'m, P> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Has the preference been modified from its original value?
|
||||
pub fn is_default(&self, key: &str) -> Result<bool, PrefError> {
|
||||
if let Some(accessor) = self.accessors.get(key) {
|
||||
let user = (accessor.getter)(&self.default_prefs);
|
||||
let default = (accessor.getter)(&self.user_prefs.read().unwrap());
|
||||
Ok(default == user)
|
||||
} else {
|
||||
Err(PrefError::NoSuchPref(String::from(key)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates an iterator over all keys and values
|
||||
pub fn iter<'a>(&'a self) -> impl Iterator<Item = (String, PrefValue)> + 'a {
|
||||
let prefs = self.user_prefs.read().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue