pub trait Get {
    type Out;

    fn get(self, entity: EntityId) -> Result<Self::Out, MissingComponent>;
}
Expand description

Retrieves components based on their type and entity id.

Required Associated Types

Required Methods

Retrieve components of entity.

Multiple components can be queried at the same time using a tuple.

Example:
use shipyard::{Component, Get, View, World};

#[derive(Component, Debug, PartialEq, Eq)]
struct U32(u32);

#[derive(Component, Debug, PartialEq, Eq)]
struct USIZE(usize);

let mut world = World::new();

let entity = world.add_entity((USIZE(0), U32(1)));

let (usizes, u32s) = world.borrow::<(View<USIZE>, View<U32>)>().unwrap();
assert_eq!((&usizes, &u32s).get(entity), Ok((&USIZE(0), &U32(1))));

Implementations on Foreign Types

Implementors