Trait libreda_db::property_storage::WithProperties
source · [−]pub trait WithProperties {
type Key: Hash + Eq;
fn with_properties<F, R>(&self, f: F) -> R
where
F: FnOnce(Option<&PropertyStore<Self::Key>>) -> R;
fn with_properties_mut<F, R>(&self, f: F) -> R
where
F: FnOnce(&mut PropertyStore<Self::Key>) -> R;
fn property<Q: ?Sized>(&self, key: &Q) -> Option<PropertyValue>
where
Self::Key: Borrow<Q>,
Q: Eq + Hash,
{ ... }
fn property_str<Q: ?Sized>(&self, key: &Q) -> Option<RcString>
where
Self::Key: Borrow<Q>,
Q: Eq + Hash,
{ ... }
fn set_property<V: Into<PropertyValue>>(
&self,
key: Self::Key,
value: V
) -> Option<PropertyValue> { ... }
}
Expand description
A trait for associating user defined properties with a type.
Required Associated Types
Required Methods
fn with_properties<F, R>(&self, f: F) -> R where
F: FnOnce(Option<&PropertyStore<Self::Key>>) -> R,
fn with_properties<F, R>(&self, f: F) -> R where
F: FnOnce(Option<&PropertyStore<Self::Key>>) -> R,
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
.
fn with_properties_mut<F, R>(&self, f: F) -> R where
F: FnOnce(&mut PropertyStore<Self::Key>) -> R,
fn with_properties_mut<F, R>(&self, f: F) -> R where
F: FnOnce(&mut PropertyStore<Self::Key>) -> R,
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.
fn set_property<V: Into<PropertyValue>>(
&self,
key: Self::Key,
value: V
) -> Option<PropertyValue>
fn set_property<V: Into<PropertyValue>>(
&self,
key: Self::Key,
value: V
) -> Option<PropertyValue>
Insert a property. Returns the old property value if there was already a property stored under this key.