pub trait Props {
// Required method
fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
where F: FnMut(Str<'kv>, Value<'kv>) -> ControlFlow<()>;
// Provided methods
fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>
where K: ToStr { ... }
fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
where V: FromValue<'kv>,
K: ToStr { ... }
fn is_unique(&self) -> bool { ... }
fn and_props<U>(self, other: U) -> And<Self, U>
where U: Props,
Self: Sized { ... }
fn as_map(&self) -> &AsMap<Self>
where Self: Sized { ... }
fn dedup(&self) -> &Dedup<Self>
where Self: Sized { ... }
}
Expand description
A collection of Str
and Value
pairs.
The Props::for_each
method can be used to enumerate properties.
§Uniqueness
Properties may be duplicated in a set of Props
. When a property is duplicated, the first for a given key is the one to use.
§Typed and untyped properties
The Props::get
method will return a property as an untyped Value
that can be formatted or serialized. If you’re looking for a specific type, you can use Props::pull
instead.
Required Methods§
Sourcefn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
fn for_each<'kv, F>(&'kv self, for_each: F) -> ControlFlow<()>
Provided Methods§
Sourcefn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>where
K: ToStr,
fn get<'v, K>(&'v self, key: K) -> Option<Value<'v>>where
K: ToStr,
Get the value for a given key, if it’s present.
If the key is present then this method will return Some
. Otherwise this method will return None
.
If the key appears multiple times, the first value seen should be returned.
Implementors are encouraged to override this method with a more efficient implementation.
Sourcefn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
fn pull<'kv, V, K>(&'kv self, key: K) -> Option<V>
Get the value for a given key, if it’s present as an instance of V
.
If the key is present, and the raw value can be converted into V
through Value::cast
then this method will return Some
. Otherwise this method will return None
.
If the key appears multiple times, the first value seen should be returned.
Sourcefn is_unique(&self) -> bool
fn is_unique(&self) -> bool
Whether the collection is known not to contain any duplicate keys.
If there’s any possibility a key may be duplicated, this method should return false
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.