pub struct Properties { /* private fields */ }
Expand description
Map of property names to property values.
It features O(log n) lookup and preserves insertion order, as well as convenience methods for type-safe access and parsing of values.
This structure is case-sensitive. It’s the caller’s responsibility to ensure all keys and values are lowercased.
Implementations§
Source§impl Properties
impl Properties
Sourcepub const fn new() -> Properties
pub const fn new() -> Properties
Constructs a new empty Properties
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of key-value pairs, including those with empty values.
Sourcepub fn get_raw_for_key(&self, key: impl AsRef<str>) -> &RawValue
pub fn get_raw_for_key(&self, key: impl AsRef<str>) -> &RawValue
Returns the unparsed “raw” value for the specified key.
Does not test for the “unset” value. Use RawValue::filter_unset
.
Sourcepub fn get_raw<T: PropertyKey>(&self) -> &RawValue
pub fn get_raw<T: PropertyKey>(&self) -> &RawValue
Returns the unparsed “raw” value for the specified property.
Does not test for the “unset” value. Use RawValue::filter_unset
.
Sourcepub fn get<T: PropertyKey + PropertyValue>(&self) -> Result<T, &RawValue>
pub fn get<T: PropertyKey + PropertyValue>(&self) -> Result<T, &RawValue>
Returns the parsed value for the specified property.
Does not test for the “unset” value if parsing fails. Use RawValue::filter_unset
.
Sourcepub fn iter(&self) -> Iter<'_>
pub fn iter(&self) -> Iter<'_>
Returns an iterator over the key-value pairs.
If the allow-empty-values
feature is NOT used,
key-value pairs where the value is empty will be skipped.
Otherwise, they will be returned as normal.
Pairs are returned from oldest to newest.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_>
pub fn iter_mut(&mut self) -> IterMut<'_>
Returns an iterator over the key-value pairs that allows mutation of the values.
If the allow-empty-values
feature is NOT used,
key-value pairs where the value is empty will be skipped.
Otherwise, they will be returned as normal.
Pairs are returned from oldest to newest.
Sourcepub fn insert_raw_for_key(
&mut self,
key: impl AsRef<str>,
val: impl Into<RawValue>,
)
pub fn insert_raw_for_key( &mut self, key: impl AsRef<str>, val: impl Into<RawValue>, )
Sets the value for a specified key.
Sourcepub fn insert_raw<K: PropertyKey, V: Into<RawValue>>(&mut self, val: V)
pub fn insert_raw<K: PropertyKey, V: Into<RawValue>>(&mut self, val: V)
Sets the value for a specified property’s key.
Sourcepub fn insert<T: PropertyKey + Into<RawValue>>(&mut self, prop: T)
pub fn insert<T: PropertyKey + Into<RawValue>>(&mut self, prop: T)
Inserts a specified property into the map.
Sourcepub fn try_insert_raw_for_key(
&mut self,
key: impl AsRef<str>,
value: impl Into<RawValue>,
) -> Result<(), &mut RawValue>
pub fn try_insert_raw_for_key( &mut self, key: impl AsRef<str>, value: impl Into<RawValue>, ) -> Result<(), &mut RawValue>
Attempts to add a new key-value pair to the map.
If the key was already associated with a value, returns a mutable reference to the old value and does not update the map.
Sourcepub fn try_insert_raw<K: PropertyKey, V: Into<RawValue>>(
&mut self,
val: V,
) -> Result<(), &mut RawValue>
pub fn try_insert_raw<K: PropertyKey, V: Into<RawValue>>( &mut self, val: V, ) -> Result<(), &mut RawValue>
Attempts to add a new property to the map with a specified value.
If the key was already associated with a value, returns a mutable reference to the old value and does not update the map.
Sourcepub fn try_insert<T: PropertyKey + Into<RawValue>>(
&mut self,
prop: T,
) -> Result<(), &mut RawValue>
pub fn try_insert<T: PropertyKey + Into<RawValue>>( &mut self, prop: T, ) -> Result<(), &mut RawValue>
Attempts to add a new property to the map.
If the key was already associated with a value, returns a mutable reference to the old value and does not update the map.
Sourcepub fn use_fallbacks(&mut self)
pub fn use_fallbacks(&mut self)
Adds fallback values for certain common key-value pairs.
Used to obtain spec-compliant values for crate::property::IndentSize
and crate::property::TabWidth
.
Sourcepub fn use_fallbacks_legacy(&mut self)
pub fn use_fallbacks_legacy(&mut self)
Adds pre-0.9.0 fallback values for certain common key-value pairs.
This shouldn’t be used outside of narrow cases where
compatibility with those older standards is required.
Prefer Properties::use_fallbacks
instead.
Trait Implementations§
Source§impl Clone for Properties
impl Clone for Properties
Source§fn clone(&self) -> Properties
fn clone(&self) -> Properties
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Properties
impl Debug for Properties
Source§impl Default for Properties
impl Default for Properties
Source§fn default() -> Properties
fn default() -> Properties
Source§impl<K: AsRef<str>, V: Into<RawValue>> Extend<(K, V)> for Properties
impl<K: AsRef<str>, V: Into<RawValue>> Extend<(K, V)> for Properties
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<K: AsRef<str>, V: Into<RawValue>> FromIterator<(K, V)> for Properties
impl<K: AsRef<str>, V: Into<RawValue>> FromIterator<(K, V)> for Properties
Source§impl<'a> IntoIterator for &'a Properties
impl<'a> IntoIterator for &'a Properties
Source§impl<'a> IntoIterator for &'a mut Properties
impl<'a> IntoIterator for &'a mut Properties
Source§impl PartialEq for Properties
impl PartialEq for Properties
Source§impl<'a> PropertiesSource for &'a Properties
impl<'a> PropertiesSource for &'a Properties
Source§fn apply_to(
self,
props: &mut Properties,
_: impl AsRef<Path>,
) -> Result<(), Error>
fn apply_to( self, props: &mut Properties, _: impl AsRef<Path>, ) -> Result<(), Error>
Properties
.