Trait shipyard::prelude::System [−][src]
pub trait System<'a> {
type Data: SystemData<'a>;
fn run(storage: <Self::Data as SystemData<'a>>::View);
}
Expand description
Trait to define systems.
System::Data
can be:
&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
- ThreadPool for a shared access to the
ThreadPool
used by the World - Unique<&T> for a shared access to a
T
unique storage - Unique<&mut T> for an exclusive access to a
T
unique storage NonSend<&T>
for a shared access to aT
storage whereT
isn’tSend
NonSend<&mut T>
for an exclusive access to aT
storage whereT
isn’tSend
NonSync<&T>
for a shared access to aT
storage whereT
isn’tSync
NonSync<&mut T>
for an exclusive access to aT
storage whereT
isn’tSync
NonSendSync<&T>
for a shared access to aT
storage whereT
isn’tSend
norSync
NonSendSync<&mut T>
for an exclusive access to aT
storage whereT
isn’tSend
norSync
Unique and NonSend
/NonSync
/NonSendSync
can be used together to access a unique storage missing Send
and/or Sync
bound(s).
A tuple will allow multiple references.
Example
struct Single;
impl<'a> System<'a> for Single {
type Data = &'a usize;
fn run(usizes: <Self::Data as SystemData>::View) {
// -- snip --
}
}
struct Double;
impl<'a> System<'a> for Double {
type Data = (&'a usize, &'a mut u32);
fn run((usizes, u32s): <Self::Data as SystemData>::View) {
// -- snip --
}
}