Struct shipyard::AllStorages [−][src]
pub struct AllStorages { /* fields omitted */ }
Expand description
Contains all components present in the World.
Implementations
Delete an entity and all its components.
Returns true
if entity
was alive.
Example
let world = World::new();
let (mut entities, mut usizes, mut u32s) = world.borrow::<(EntitiesMut, &mut usize, &mut u32)>();
let entity1 = entities.add_entity((&mut usizes, &mut u32s), (0usize, 1u32));
let entity2 = entities.add_entity((&mut usizes, &mut u32s), (2usize, 3u32));
drop((entities, usizes, u32s));
world.run::<AllStorages, _, _>(|mut all_storages| {
all_storages.delete(entity1);
});
world.run::<(&usize, &u32), _, _>(|(usizes, u32s)| {
assert!((&usizes).get(entity1).is_err());
assert!((&u32s).get(entity1).is_err());
assert_eq!(usizes.get(entity2), Ok(&2));
assert_eq!(u32s.get(entity2), Ok(&3));
});
Deletes all components from an entity without deleting it.
pub fn try_borrow<'a, C: StorageBorrow<'a>>(
&'a self
) -> Result<<C as StorageBorrow<'a>>::View, GetStorage>
pub fn try_borrow<'a, C: StorageBorrow<'a>>(
&'a self
) -> Result<<C as StorageBorrow<'a>>::View, GetStorage>
Borrows the requested storage, if it doesn’t exist it’ll get created.
You can use:
&T
for a shared access toT
storage&mut T
for an exclusive access toT
storage- Entities for a shared access to the entity storage
- EntitiesMut for an exclusive reference to the entity storage
- AllStorages for an exclusive access to the storage of all components
- Unique<&T> for a shared access to a
T
unique storage - Unique<&mut T> for an exclusive access to a
T
unique storage - ThreadPool for a shared access to the
ThreadPool
used by the World - NonSend: must activate the non_send feature
- NonSync: must activate the non_sync feature
- NonSendSync: must activate the non_send and non_sync features
Example
let world = World::new();
let all_storages = world.borrow::<AllStorages>();
let u32s = all_storages.try_borrow::<&u32>().unwrap();
Borrows the requested storage, if it doesn’t exist it’ll get created.
Unwraps errors.
You can use:
&T
for a shared access toT
storage&mut T
for an exclusive access toT
storage- Entities for a shared access to the entity storage
- EntitiesMut for an exclusive reference to the entity storage
- AllStorages for an exclusive access to the storage of all components
- Unique<&T> for a shared access to a
T
unique storage - Unique<&mut T> for an exclusive access to a
T
unique storage - ThreadPool for a shared access to the
ThreadPool
used by the World - NonSend: must activate the non_send feature
- NonSync: must activate the non_sync feature
- NonSendSync: must activate the non_send and non_sync features
Example
let world = World::new();
let all_storages = world.borrow::<AllStorages>();
let u32s = all_storages.borrow::<&u32>();
Trait Implementations
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.
type Error = GetStorage
type Error = GetStorage
The type returned in the event of a conversion error.
Performs the conversion.