Struct shipyard::AllStoragesViewMut [−][src]
pub struct AllStoragesViewMut<'a>(_);
Expand description
Exclusive view over AllStorages
.
Methods from Deref<Target = AllStorages>
Delete an entity and all its components.
Returns true
if entity
was alive.
Example
use shipyard::{AllStoragesViewMut, EntitiesViewMut, Get, View, ViewMut, World};
let world = World::new();
let [entity1, entity2] = world.run(
|mut entities: EntitiesViewMut, mut usizes: ViewMut<usize>, mut u32s: ViewMut<u32>| {
[
entities.add_entity((&mut usizes, &mut u32s), (0usize, 1u32)),
entities.add_entity((&mut usizes, &mut u32s), (2usize, 3u32)),
]
},
);
world.run(|mut all_storages: AllStoragesViewMut| {
all_storages.delete(entity1);
});
world.run(|usizes: View<usize>, u32s: View<u32>| {
assert!((&usizes).try_get(entity1).is_err());
assert!((&u32s).try_get(entity1).is_err());
assert_eq!(usizes.try_get(entity2), Ok(&2));
assert_eq!(u32s.try_get(entity2), Ok(&3));
});
Deletes all components from an entity without deleting it.
Borrows the requested storage(s), if it doesn’t exist it’ll get created.
You can use a tuple to get multiple storages at once.
You can use:
- View<T> for a shared access to
T
storage - ViewMut<T> for an exclusive access to
T
storage - EntitiesView for a shared access to the entity storage
- EntitiesViewMut for an exclusive reference to the entity storage
- UniqueView<T> for a shared access to a
T
unique storage - UniqueViewMut<T> for an exclusive access to a
T
unique storage - This is supported on
feature=“non_send”
only:- NonSend<View<T>> for a shared access to a
T
storage whereT
isn’tSend
- NonSend<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
NonSend and UniqueView/UniqueViewMut can be used together to access a!Send
unique storage.
- NonSend<View<T>> for a shared access to a
- This is supported on
feature=“non_sync”
only:- NonSync<View<T>> for a shared access to a
T
storage whereT
isn’tSync
- NonSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSync
NonSync and UniqueView/UniqueViewMut can be used together to access a!Sync
unique storage.
- NonSync<View<T>> for a shared access to a
- This is supported on
feature=“non_send”
andfeature=“non_sync”
only:- NonSendSync<View<T>> for a shared access to a
T
storage whereT
isn’tSend
norSync
- NonSendSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
norSync
NonSendSync and UniqueView/UniqueViewMut can be used together to access a!Send + !Sync
unique storage.
- NonSendSync<View<T>> for a shared access to a
Example
use shipyard::{AllStoragesViewMut, EntitiesView, View, ViewMut, World};
let world = World::new();
world.run(|all_storages: AllStoragesViewMut| {
let u32s = all_storages.try_borrow::<View<u32>>().unwrap();
let (entities, mut usizes) = all_storages
.try_borrow::<(EntitiesView, ViewMut<usize>)>()
.unwrap();
});
Borrows the requested storage(s), if it doesn’t exist it’ll get created.
You can use a tuple to get multiple storages at once.
Unwraps errors.
You can use:
- View<T> for a shared access to
T
storage - ViewMut<T> for an exclusive access to
T
storage - EntitiesView for a shared access to the entity storage
- EntitiesViewMut for an exclusive reference to the entity storage
- UniqueView<T> for a shared access to a
T
unique storage - UniqueViewMut<T> for an exclusive access to a
T
unique storage - This is supported on
feature=“non_send”
only:- NonSend<View<T>> for a shared access to a
T
storage whereT
isn’tSend
- NonSend<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
NonSend and UniqueView/UniqueViewMut can be used together to access a!Send
unique storage.
- NonSend<View<T>> for a shared access to a
- This is supported on
feature=“non_sync”
only:- NonSync<View<T>> for a shared access to a
T
storage whereT
isn’tSync
- NonSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSync
NonSync and UniqueView/UniqueViewMut can be used together to access a!Sync
unique storage.
- NonSync<View<T>> for a shared access to a
- This is supported on
feature=“non_send”
andfeature=“non_sync”
only:- NonSendSync<View<T>> for a shared access to a
T
storage whereT
isn’tSend
norSync
- NonSendSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
norSync
NonSendSync and UniqueView/UniqueViewMut can be used together to access a!Send + !Sync
unique storage.
- NonSendSync<View<T>> for a shared access to a
Example
use shipyard::{AllStoragesViewMut, EntitiesView, View, ViewMut, World};
let world = World::new();
world.run(|all_storages: AllStoragesViewMut| {
let u32s = all_storages.try_borrow::<View<u32>>().unwrap();
let (entities, mut usizes) = all_storages.borrow::<(EntitiesView, ViewMut<usize>)>();
});
Borrows the requested storages and runs the function.
You can use:
- View<T> for a shared access to
T
storage - ViewMut<T> for an exclusive access to
T
storage - EntitiesView for a shared access to the entity storage
- EntitiesViewMut for an exclusive reference to the entity storage
- UniqueView<T> for a shared access to a
T
unique storage - UniqueViewMut<T> for an exclusive access to a
T
unique storage - This is supported on
feature=“non_send”
only:- NonSend<View<T>> for a shared access to a
T
storage whereT
isn’tSend
- NonSend<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
NonSend and UniqueView/UniqueViewMut can be used together to access a!Send
unique storage.
- NonSend<View<T>> for a shared access to a
- This is supported on
feature=“non_sync”
only:- NonSync<View<T>> for a shared access to a
T
storage whereT
isn’tSync
- NonSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSync
NonSync and UniqueView/UniqueViewMut can be used together to access a!Sync
unique storage.
- NonSync<View<T>> for a shared access to a
- This is supported on
feature=“non_send”
andfeature=“non_sync”
only:- NonSendSync<View<T>> for a shared access to a
T
storage whereT
isn’tSend
norSync
- NonSendSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
norSync
NonSendSync and UniqueView/UniqueViewMut can be used together to access a!Send + !Sync
unique storage.
- NonSendSync<View<T>> for a shared access to a
Example
use shipyard::{AllStoragesViewMut, View, ViewMut, World};
fn sys1(i32s: View<i32>) -> i32 {
0
}
let world = World::new();
let all_storages = world.borrow::<AllStoragesViewMut>();
all_storages
.try_run(|usizes: View<usize>, mut u32s: ViewMut<u32>| {
// -- snip --
})
.unwrap();
let i = all_storages.try_run(sys1).unwrap();
Borrows the requested storages and runs the function.
You can use:
- View<T> for a shared access to
T
storage - ViewMut<T> for an exclusive access to
T
storage - EntitiesView for a shared access to the entity storage
- EntitiesViewMut for an exclusive reference to the entity storage
- UniqueView<T> for a shared access to a
T
unique storage - UniqueViewMut<T> for an exclusive access to a
T
unique storage - This is supported on
feature=“non_send”
only:- NonSend<View<T>> for a shared access to a
T
storage whereT
isn’tSend
- NonSend<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
NonSend and UniqueView/UniqueViewMut can be used together to access a!Send
unique storage.
- NonSend<View<T>> for a shared access to a
- This is supported on
feature=“non_sync”
only:- NonSync<View<T>> for a shared access to a
T
storage whereT
isn’tSync
- NonSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSync
NonSync and UniqueView/UniqueViewMut can be used together to access a!Sync
unique storage.
- NonSync<View<T>> for a shared access to a
- This is supported on
feature=“non_send”
andfeature=“non_sync”
only:- NonSendSync<View<T>> for a shared access to a
T
storage whereT
isn’tSend
norSync
- NonSendSync<ViewMut<T>> for an exclusive access to a
T
storage whereT
isn’tSend
norSync
NonSendSync and UniqueView/UniqueViewMut can be used together to access a!Send + !Sync
unique storage.
- NonSendSync<View<T>> for a shared access to a
Example
use shipyard::{AllStoragesViewMut, View, ViewMut, World};
fn sys1(i32s: View<i32>) -> i32 {
0
}
let world = World::new();
let all_storages = world.borrow::<AllStoragesViewMut>();
all_storages.run(|usizes: View<usize>, mut u32s: ViewMut<u32>| {
// -- snip --
});
let i = all_storages.run(sys1);
Trait Implementations
type Target = AllStorages
type Target = AllStorages
The resulting type after dereferencing.