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.

Deletes all entities and their components.

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:
  • This is supported on feature=“non_sync” only:
  • This is supported on feature=“non_send” and feature=“non_sync” only:

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:
  • This is supported on feature=“non_sync” only:
  • This is supported on feature=“non_send” and feature=“non_sync” only:

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:
  • This is supported on feature=“non_sync” only:
  • This is supported on feature=“non_send” and feature=“non_sync” only:

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:
  • This is supported on feature=“non_sync” only:
  • This is supported on feature=“non_send” and feature=“non_sync” only:

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

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

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 alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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.