Struct servo_config::pref_util::Preferences
source · pub struct Preferences<'m, P> {
user_prefs: RwLock<P>,
default_prefs: P,
accessors: &'m HashMap<String, Accessor<P, PrefValue>>,
}
Fields§
§user_prefs: RwLock<P>
§default_prefs: P
§accessors: &'m HashMap<String, Accessor<P, PrefValue>>
Implementations§
source§impl<'m, P: Clone> Preferences<'m, P>
impl<'m, P: Clone> Preferences<'m, P>
sourcepub fn new(
default_prefs: P,
accessors: &'m HashMap<String, Accessor<P, PrefValue>>,
) -> Self
pub fn new( default_prefs: P, accessors: &'m HashMap<String, Accessor<P, PrefValue>>, ) -> Self
Create a new Preferences
object. The values provided in default_prefs
are immutable and
can always be restored using reset
or reset_all
.
sourcepub fn is_default(&self, key: &str) -> Result<bool, PrefError>
pub fn is_default(&self, key: &str) -> Result<bool, PrefError>
Has the preference been modified from its original value?
sourcepub fn iter(&self) -> impl Iterator<Item = (String, PrefValue)> + '_
pub fn iter(&self) -> impl Iterator<Item = (String, PrefValue)> + '_
Creates an iterator over all keys and values
fn set_inner<V>( &self, key: &str, prefs: &mut P, val: V, ) -> Result<(), PrefError>
sourcepub fn set<V>(&self, key: &str, val: V) -> Result<(), PrefError>
pub fn set<V>(&self, key: &str, val: V) -> Result<(), PrefError>
Set a new value for a preference, using its key.
pub fn set_all<M>(&self, values: M) -> Result<(), PrefError>
pub fn reset(&self, key: &str) -> Result<PrefValue, PrefError>
pub fn reset_all(&self)
Auto Trait Implementations§
impl<'m, P> !Freeze for Preferences<'m, P>
impl<'m, P> !RefUnwindSafe for Preferences<'m, P>
impl<'m, P> Send for Preferences<'m, P>where
P: Send,
impl<'m, P> Sync for Preferences<'m, P>
impl<'m, P> Unpin for Preferences<'m, P>where
P: Unpin,
impl<'m, P> !UnwindSafe for Preferences<'m, P>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert