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 and_props<U>(self, other: U) -> And<Self, U>
where U: Props,
Self: Sized { ... }
fn filter<F>(self, filter: F) -> Filter<Self, F>
where F: Fn(Str<'_>, Value<'_>) -> bool,
Self: Sized { ... }
fn collect<'kv, C>(&'kv self) -> C
where C: FromProps<'kv> { ... }
fn as_map(&self) -> &AsMap<Self>
where Self: Sized { ... }
fn dedup(&self) -> &Dedup<Self>
where Self: Sized { ... }
fn is_unique(&self) -> bool { ... }
fn size(&self) -> Option<usize> { ... }
}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 filter<F>(self, filter: F) -> Filter<Self, F>
fn filter<F>(self, filter: F) -> Filter<Self, F>
Filter the set of properties.
Only properties where the filter F returns true will be included.
Sourcefn collect<'kv, C>(&'kv self) -> Cwhere
C: FromProps<'kv>,
fn collect<'kv, C>(&'kv self) -> Cwhere
C: FromProps<'kv>,
Collect these properties into another collection type.
This method defers to the FromProps implementation on C.
Sourcefn as_map(&self) -> &AsMap<Self>where
Self: Sized,
fn as_map(&self) -> &AsMap<Self>where
Self: Sized,
Get an adapter that will serialize properties as a map.
Sourcefn dedup(&self) -> &Dedup<Self>where
Self: Sized,
fn dedup(&self) -> &Dedup<Self>where
Self: Sized,
Lazily de-duplicate properties in the collection.
Properties are de-duplicated by taking the first value for a given key.
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.
Sourcefn size(&self) -> Option<usize>
fn size(&self) -> Option<usize>
A hint on the number of properties in the collection.
The returned size isn’t guaranteed to be exact, but should not be less than the number of times Props::for_each will call its given closure.
If the collection can’t determine its size without needing to walk its values then this method will return None.
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.
Implementations on Foreign Types§
Source§impl<'a, P> Props for &'a P
impl<'a, P> Props for &'a P
Source§impl<'a, P> Props for Box<P>
Available on crate feature alloc only.
impl<'a, P> Props for Box<P>
alloc only.Source§impl<'a, P> Props for Arc<P>
Available on crate feature alloc only.
impl<'a, P> Props for Arc<P>
alloc only.