pub struct Metadata(/* private fields */);Expand description
A type-erased container for metadata that can be associated with computation results.
Metadata allows attaching arbitrary typed information to computation results
and passing it through the computation pipeline.
It holds at most a handful of entries (typically none, sometimes an
animation), so it is a boxed slice searched linearly: an empty Metadata
does not allocate, and cloning an empty one is free.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn get<T>(&self) -> Twhere
T: 'static + Clone,
pub fn get<T>(&self) -> Twhere
T: 'static + Clone,
Gets a value of type T from the metadata.
§Panics
Panics if no value of type T is present in the metadata.
Sourcepub fn try_get<T>(&self) -> Option<T>where
T: 'static + Clone,
pub fn try_get<T>(&self) -> Option<T>where
T: 'static + Clone,
Attempts to get a value of type T from the metadata.
Returns None if no value of the requested type is present.
Sourcepub fn with<T>(self, value: T) -> Metadatawhere
T: 'static + Clone,
pub fn with<T>(self, value: T) -> Metadatawhere
T: 'static + Clone,
Adds a value to the metadata and returns the updated metadata.
A value of the same type that is already present is replaced. This method is chainable for fluent API usage.
Sourcepub fn merge(self, other: Metadata) -> Metadata
pub fn merge(self, other: Metadata) -> Metadata
Merges other into self, returning the union: a value already
present under the same type is replaced by other’s.
Deferred notifications (such as a batched List change) compose
their metadata this way, so the single notification they finally
send carries what the individual ones would have.