pub trait WithProperties {
    type Key: Hash + Eq;

    fn with_properties<F, R>(&self, f: F) -> R
        F: FnOnce(Option<&PropertyStore<Self::Key>>) -> R
; fn with_properties_mut<F, R>(&self, f: F) -> R
        F: FnOnce(&mut PropertyStore<Self::Key>) -> R
; fn property<Q: ?Sized>(&self, key: &Q) -> Option<PropertyValue>
        Self::Key: Borrow<Q>,
        Q: Eq + Hash
, { ... } fn property_str<Q: ?Sized>(&self, key: &Q) -> Option<RcString>
        Self::Key: Borrow<Q>,
        Q: Eq + Hash
, { ... } fn set_property<V: Into<PropertyValue>>(
        key: Self::Key,
        value: V
    ) -> Option<PropertyValue> { ... } }
Expand description

A trait for associating user defined properties with a type.

Required Associated Types

Property key type.

Required Methods

Call a function with maybe the property storage as argument.

The property store might not always be initialized. For instance for objects without any defined properties, it will likely be None.

Get mutable reference to the property storage.

Provided Methods

Get a property value by the property key.

Get a string property value by key. If the property value is not a string None is returned.

Insert a property. Returns the old property value if there was already a property stored under this key.