Struct shipyard::WorkloadSystem
source · pub struct WorkloadSystem {Show 13 fields
pub type_id: TypeId,
pub display_name: Box<dyn Label>,
pub system_fn: Box<dyn Fn(&World) -> Result<(), Run> + Send + Sync + 'static>,
pub borrow_constraints: Vec<TypeInfo>,
pub tracking_to_enable: Vec<fn(_: &AllStorages) -> Result<(), GetStorage>>,
pub generator: Box<dyn Fn(&mut Vec<TypeInfo>) -> TypeId + Send + Sync + 'static>,
pub run_if: Option<Box<dyn Fn(&World) -> Result<bool, Run> + Send + Sync + 'static>>,
pub tags: Vec<Box<dyn Label>>,
pub before_all: DedupedLabels,
pub after_all: DedupedLabels,
pub require_in_workload: DedupedLabels,
pub require_before: DedupedLabels,
pub require_after: DedupedLabels,
}
Expand description
Self contained system that may be inserted into a Workload
.
§Example:
use shipyard::{Component, IntoWorkloadSystem, View, Workload, WorkloadSystem, World};
#[derive(Component)]
struct U32(u32);
#[derive(Component)]
struct USIZE(usize);
fn sys1(u32s: View<U32>) {}
fn sys2(usizes: View<USIZE>) {}
let workload_sys1: WorkloadSystem = sys1.into_workload_system().unwrap();
let mut workload = Workload::new("my_workload")
.with_system(workload_sys1)
.with_system(sys2);
Fields§
§type_id: TypeId
§display_name: Box<dyn Label>
§system_fn: Box<dyn Fn(&World) -> Result<(), Run> + Send + Sync + 'static>
§borrow_constraints: Vec<TypeInfo>
access information
tracking_to_enable: Vec<fn(_: &AllStorages) -> Result<(), GetStorage>>
Generates the tracking to enable for this system’s views
generator: Box<dyn Fn(&mut Vec<TypeInfo>) -> TypeId + Send + Sync + 'static>
Generates constraints and system type id
run_if: Option<Box<dyn Fn(&World) -> Result<bool, Run> + Send + Sync + 'static>>
§before_all: DedupedLabels
§after_all: DedupedLabels
§require_in_workload: DedupedLabels
§require_before: DedupedLabels
§require_after: DedupedLabels
Trait Implementations§
source§impl Extend<WorkloadSystem> for Workload
impl Extend<WorkloadSystem> for Workload
source§fn extend<T: IntoIterator<Item = WorkloadSystem>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = WorkloadSystem>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl IntoWorkloadSystem<WorkloadSystem, ()> for WorkloadSystem
impl IntoWorkloadSystem<WorkloadSystem, ()> for WorkloadSystem
source§fn into_workload_system(self) -> Result<WorkloadSystem, InvalidSystem>
fn into_workload_system(self) -> Result<WorkloadSystem, InvalidSystem>
Wraps a function in a struct containing all information required by a workload.
source§impl IntoWorkloadTrySystem<WorkloadSystem, Result<(), InvalidSystem>> for WorkloadSystem
impl IntoWorkloadTrySystem<WorkloadSystem, Result<(), InvalidSystem>> for WorkloadSystem
source§fn into_workload_try_system<Ok, Err: Into<Box<dyn Error + Send + Sync>>>(
self,
) -> Result<WorkloadSystem, InvalidSystem>
fn into_workload_try_system<Ok, Err: Into<Box<dyn Error + Send + Sync>>>( self, ) -> Result<WorkloadSystem, InvalidSystem>
Wraps a fallible function in a struct containing all information required by a workload.
The workload will stop if an error is returned.
source§impl SystemModificator<WorkloadSystem, ()> for WorkloadSystem
impl SystemModificator<WorkloadSystem, ()> for WorkloadSystem
source§fn run_if<RunB, Run: IntoRunIf<RunB>>(self, run_if: Run) -> WorkloadSystem
fn run_if<RunB, Run: IntoRunIf<RunB>>(self, run_if: Run) -> WorkloadSystem
Only run the system if the function evaluates to
true
.source§fn skip_if<RunB, Run: IntoRunIf<RunB>>(self, run_if: Run) -> WorkloadSystem
fn skip_if<RunB, Run: IntoRunIf<RunB>>(self, run_if: Run) -> WorkloadSystem
Do not run the system if the function evaluates to
true
.source§fn before_all<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
fn before_all<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
When building a workload, this system will be placed before all invocation of the other system or workload.
source§fn after_all<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
fn after_all<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
When building a workload, this system will be placed after all invocation of the other system or workload.
source§fn display_name<T>(self, name: impl AsLabel<T>) -> WorkloadSystem
fn display_name<T>(self, name: impl AsLabel<T>) -> WorkloadSystem
System name used in error and gui built for shipyard.
Defaults to the system function name.
Defaults to the system function name.
source§fn tag<T>(self, tag: impl AsLabel<T>) -> WorkloadSystem
fn tag<T>(self, tag: impl AsLabel<T>) -> WorkloadSystem
Adds a tag to this system. Tags can be used to control system ordering when running workloads.
source§fn require_in_workload<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
fn require_in_workload<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
When building a workload, this system will assert that at least one of the other system is present in the workload. Read more
source§fn require_before<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
fn require_before<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
When building a workload, this system will assert that at least one of the other system is present before itself in the workload. Read more
source§fn require_after<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
fn require_after<T>(self, other: impl AsLabel<T>) -> WorkloadSystem
When building a workload, this system will assert that at least one of the other system is present after itself in the workload. Read more
source§fn run_if_storage_empty<T: Component>(self) -> WorkloadSystemwhere
Self: Sized,
fn run_if_storage_empty<T: Component>(self) -> WorkloadSystemwhere
Self: Sized,
Only run the system if the
T
storage is empty. Read moresource§fn run_if_missing_unique<T: Unique>(self) -> WorkloadSystemwhere
Self: Sized,
fn run_if_missing_unique<T: Unique>(self) -> WorkloadSystemwhere
Self: Sized,
Only run the system if the
T
unique storage is not present in the World
.source§fn run_if_storage_empty_by_id(self, storage_id: StorageId) -> WorkloadSystemwhere
Self: Sized,
fn run_if_storage_empty_by_id(self, storage_id: StorageId) -> WorkloadSystemwhere
Self: Sized,
Only run the system if the storage is empty. Read more
source§fn skip_if_storage_empty<T: Component>(self) -> WorkloadSystemwhere
Self: Sized,
fn skip_if_storage_empty<T: Component>(self) -> WorkloadSystemwhere
Self: Sized,
Do not run the system if the
T
storage is empty. Read moresource§fn skip_if_missing_unique<T: Unique>(self) -> WorkloadSystemwhere
Self: Sized,
fn skip_if_missing_unique<T: Unique>(self) -> WorkloadSystemwhere
Self: Sized,
Do not run the system if the
T
unique storage is not present in the World
.source§fn skip_if_storage_empty_by_id(self, storage_id: StorageId) -> WorkloadSystemwhere
Self: Sized,
fn skip_if_storage_empty_by_id(self, storage_id: StorageId) -> WorkloadSystemwhere
Self: Sized,
Do not run the system if the storage is empty. Read more
Auto Trait Implementations§
impl Freeze for WorkloadSystem
impl !RefUnwindSafe for WorkloadSystem
impl Send for WorkloadSystem
impl Sync for WorkloadSystem
impl Unpin for WorkloadSystem
impl !UnwindSafe for WorkloadSystem
Blanket Implementations§
source§impl<Views, R, Sys> AsLabel<(Views, R)> for Syswhere
Sys: IntoWorkloadSystem<Views, R> + 'static,
R: 'static,
impl<Views, R, Sys> AsLabel<(Views, R)> for Syswhere
Sys: IntoWorkloadSystem<Views, R> + 'static,
R: 'static,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<Views, R, Sys> IntoWorkload<Views, R> for Syswhere
Sys: IntoWorkloadSystem<Views, R> + 'static,
R: 'static,
impl<Views, R, Sys> IntoWorkload<Views, R> for Syswhere
Sys: IntoWorkloadSystem<Views, R> + 'static,
R: 'static,
source§fn into_workload(self) -> Workload
fn into_workload(self) -> Workload
Converts to a collection of systems. Read more