Struct shipyard::AllStoragesView
source · [−]pub struct AllStoragesView<'a>(_);
Expand description
Shared view over AllStorages
.
Methods from Deref<Target = AllStorages>
sourcepub fn add_unique<T: Send + Sync + Unique>(&self, component: T)
pub fn add_unique<T: Send + Sync + Unique>(&self, component: T)
Adds a new unique storage, unique storages store exactly one T
at any time.
To access a unique storage value, use UniqueView
or UniqueViewMut
.
Does nothing if the storage already exists.
Example
use shipyard::{AllStoragesViewMut, Unique, World};
#[derive(Unique)]
struct USIZE(usize);
let world = World::new();
let mut all_storages = world.borrow::<AllStoragesViewMut>().unwrap();
all_storages.add_unique(USIZE(0));
sourcepub fn add_unique_non_send<T: Sync + Unique>(&self, component: T)
pub fn add_unique_non_send<T: Sync + Unique>(&self, component: T)
Adds a new unique storage, unique storages store exactly one T
at any time.
To access a unique storage value, use NonSend and UniqueViewMut or UniqueViewMut.
Does nothing if the storage already exists.
sourcepub fn add_unique_non_sync<T: Send + Unique>(&self, component: T)
pub fn add_unique_non_sync<T: Send + Unique>(&self, component: T)
Adds a new unique storage, unique storages store exactly one T
at any time.
To access a unique storage value, use NonSync and UniqueViewMut or UniqueViewMut.
Does nothing if the storage already exists.
sourcepub fn add_unique_non_send_sync<T: Unique>(&self, component: T)
pub fn add_unique_non_send_sync<T: Unique>(&self, component: T)
Adds a new unique storage, unique storages store exactly one T
at any time.
To access a unique storage value, use NonSync and UniqueViewMut or UniqueViewMut.
Does nothing if the storage already exists.
sourcepub fn remove_unique<T: Unique>(&self) -> Result<T, UniqueRemove>
pub fn remove_unique<T: Unique>(&self) -> Result<T, UniqueRemove>
Removes a unique storage.
Borrows
T
storage (exclusive)
Errors
T
storage borrow failed.T
storage did not exist.
Example
use shipyard::{AllStoragesViewMut, Unique, World};
#[derive(Unique)]
struct USIZE(usize);
let world = World::new();
let mut all_storages = world.borrow::<AllStoragesViewMut>().unwrap();
all_storages.add_unique(USIZE(0));
let i = all_storages.remove_unique::<USIZE>().unwrap();
sourcepub fn borrow<'s, V: IntoBorrow>(&'s self) -> Result<V, GetStorage> where
V::Borrow: Borrow<'s, View = V> + AllStoragesBorrow<'s>,
pub fn borrow<'s, V: IntoBorrow>(&'s self) -> Result<V, GetStorage> where
V::Borrow: Borrow<'s, View = V> + AllStoragesBorrow<'s>,
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 Option<V>
with one or multiple views for fallible access to one or more storages- This is supported on
feature=“thread_local”
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. - 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. - 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.
- NonSend<View<T>> for a shared access to a
Borrows
- Storage (exclusive or shared)
Errors
- Storage borrow failed.
- Unique storage did not exist.
Example
use shipyard::{AllStoragesViewMut, Component, EntitiesView, View, ViewMut, World};
#[derive(Component)]
struct U32(u32);
#[derive(Component)]
struct USIZE(usize);
let world = World::new();
let all_storages = world.borrow::<AllStoragesViewMut>().unwrap();
let u32s = all_storages.borrow::<View<U32>>().unwrap();
let (entities, mut usizes) = all_storages
.borrow::<(EntitiesView, ViewMut<USIZE>)>()
.unwrap();
sourcepub fn run_with_data<'s, Data, B, R, S: AllSystem<'s, (Data,), B, R>>(
&'s self,
system: S,
data: Data
) -> R
pub fn run_with_data<'s, Data, B, R, S: AllSystem<'s, (Data,), B, R>>(
&'s self,
system: S,
data: Data
) -> R
Borrows the requested storages and runs the function.
Data can be passed to the function, this always has to be a single type but you can use a tuple if needed.
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 Option<V>
with one or multiple views for fallible access to one or more storages- This is supported on
feature=“thread_local”
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. - 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. - 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.
- NonSend<View<T>> for a shared access to a
Borrows
- Storage (exclusive or shared)
Panics
- Storage borrow failed.
- Unique storage did not exist.
- Error returned by user.
sourcepub fn run<'s, B, R, S: AllSystem<'s, (), B, R>>(&'s self, system: S) -> R
pub fn run<'s, B, R, S: AllSystem<'s, (), B, R>>(&'s self, system: S) -> R
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 Option<V>
with one or multiple views for fallible access to one or more storages- This is supported on
feature=“thread_local”
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. - 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. - 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.
- NonSend<View<T>> for a shared access to a
Borrows
- Storage (exclusive or shared)
Panics
- Storage borrow failed.
- Unique storage did not exist.
- Error returned by user.
Example
use shipyard::{AllStoragesViewMut, Component, View, ViewMut, World};
#[derive(Component)]
struct I32(i32);
#[derive(Component)]
struct U32(u32);
#[derive(Component)]
struct USIZE(usize);
fn sys1(i32s: View<I32>) -> i32 {
0
}
let world = World::new();
let all_storages = world.borrow::<AllStoragesViewMut>().unwrap();
all_storages
.run(|usizes: View<USIZE>, mut u32s: ViewMut<U32>| {
// -- snip --
});
let i = all_storages.run(sys1);
sourcepub fn memory_usage(&self) -> AllStoragesMemoryUsage<'_>
pub fn memory_usage(&self) -> AllStoragesMemoryUsage<'_>
Displays storages memory information.
sourcepub fn get_tracking_timestamp(&self) -> TrackingTimestamp
pub fn get_tracking_timestamp(&self) -> TrackingTimestamp
Returns a timestamp used to clear tracking information.
Trait Implementations
sourceimpl AsRef<AllStorages> for AllStoragesView<'_>
impl AsRef<AllStorages> for AllStoragesView<'_>
sourcefn as_ref(&self) -> &AllStorages
fn as_ref(&self) -> &AllStorages
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<'a> BorrowInfo for AllStoragesView<'a>
impl<'a> BorrowInfo for AllStoragesView<'a>
sourcefn borrow_info(info: &mut Vec<TypeInfo>)
fn borrow_info(info: &mut Vec<TypeInfo>)
This information is used during workload creation to determine which systems can run in parallel. Read more
sourceimpl Clone for AllStoragesView<'_>
impl Clone for AllStoragesView<'_>
sourceimpl Deref for AllStoragesView<'_>
impl Deref for AllStoragesView<'_>
type Target = AllStorages
type Target = AllStorages
The resulting type after dereferencing.
sourceimpl IntoBorrow for AllStoragesView<'_>
impl IntoBorrow for AllStoragesView<'_>
type Borrow = AllStoragesBorrower
type Borrow = AllStoragesBorrower
Helper type almost allowing GAT on stable.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for AllStoragesView<'a>
impl<'a> Send for AllStoragesView<'a>
impl<'a> Sync for AllStoragesView<'a>
impl<'a> Unpin for AllStoragesView<'a>
impl<'a> !UnwindSafe for AllStoragesView<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more