Struct ecs_lib_rs::World[][src]

pub struct World { /* fields omitted */ }

Implementations

Add a resource.

use ecs_rs::World;
let mut world = World::new();
world.add_resource(1_u32);
assert_eq!(world.get_resource::<u32>(), Some(&1));

Query for a resource and get a reference to it. The type of the resource must be added in so that it can find it.

use ecs_rs::World;
let mut world = World::new();
assert_eq!(world.get_resource::<u32>(), None);
world.add_resource(1_u32);
assert_eq!(world.get_resource::<u32>(), Some(&1));

Query for a resource and get a mutable reference to it. The type of the resource must be added in so that it can find it.

use ecs_rs::World;
let mut world = World::new();
assert_eq!(world.get_resource_mut::<u32>(), None);
world.add_resource(1_u32);
{
    let x = world.get_resource_mut::<u32>();
    assert_eq!(x, Some(&mut 1_u32));
    let x = x.unwrap();
    *x += 1;
}
assert_eq!(world.get_resource::<u32>(), Some(&2));

Removes the resource from the world. Returns None if the resource wasn’t present and hence was not deleted. Otherwise, it returns Some(data)

use ecs_rs::World;
let mut world = World::new();
world.add_resource(1_u32);
world.remove_resource::<u32>();
assert_eq!(world.get_resource::<u32>(), None);

Register a component. The type of the resource must be added in so that it can find it.

use ecs_rs::World;
let mut world = World::new();
world.register_component::<u32>();

Trait Implementations

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.