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 empty MetaInfo.

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 type into this MetaInfo.

Insert a string k-v into this MetaInfo.

Check if MetaInfo contains entry

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.

Clear the MetaInfo of all inserted MetaInfo.

Extends self with the items from another MetaInfo. Only extend the items in the current scope.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.