Struct metainfo::MetaInfo [−][src]
pub struct MetaInfo { /* fields omitted */ }
Expand description
MetaInfo
is used to passthrough information between components and even client-server.
It supports two types of info: typed map and string k-v.
It is designed to be tree-like, which means you can share a MetaInfo
with multiple children.
Note: only the current scope is mutable.
Examples:
use metainfo::MetaInfo;
use std::sync::Arc;
fn test() {
let mut m1 = MetaInfo::new();
m1.insert::<i8>(2);
assert_eq!(*m1.get::<i8>().unwrap(), 2);
let mut m2 = MetaInfo::from(Arc::new(m1));
assert_eq!(*m2.get::<i8>().unwrap(), 2);
m2.insert::<i8>(4);
assert_eq!(*m2.get::<i8>().unwrap(), 4);
m2.remove::<i8>();
assert_eq!(*m2.get::<i8>().unwrap(), 2);
}
Implementations
Creates an MetaInfo
with the parent given.
When the info is not found in the current scope, MetaInfo
will try to get from parent.
Insert a string k-v into this MetaInfo
.
Check if MetaInfo
contains the given string k-v
Get a reference to a type previously inserted on this MetaInfo
.
Remove a type from this MetaInfo
and return it.
Can only remove the type in the current scope.
Get a reference to a string k-v previously inserted on this MetaInfo
.
Remove a string k-v from this MetaInfo
and return it.
Can only remove the type in the current scope.