Struct relm4::factory::collections::WeakDynamicIndex
source · pub struct WeakDynamicIndex { /* private fields */ }
Expand description
A weak version of DynamicIndex
.
Use this to send messages to the update function and call upgrade
to receive the actual DynamicIndex
.
A weak index is preferred for sending in messages because messages can be stale by the time they are handled and the element already deleted. A weak reference doesn’t keep the index alive if the element was deleted which allows you to properly handle invalid indices.
Panics
Sending a WeakDynamicIndex
to a different thread and accessing it will panic.
Implementations§
source§impl WeakDynamicIndex
impl WeakDynamicIndex
sourcepub fn upgrade(&self) -> Option<DynamicIndex>
pub fn upgrade(&self) -> Option<DynamicIndex>
Attempts to upgrade the WeakDynamicIndex
to a DynamicIndex
.
Returns None
if the index has since been dropped.