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>>§tags: Vec<Box<dyn Label>>§before_all: DedupedLabels§after_all: DedupedLabels§require_in_workload: DedupedLabels§require_before: DedupedLabels§require_after: DedupedLabels

Trait Implementations§

source§

impl Extend<WorkloadSystem> for Workload

source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

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

source§

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

source§

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

source§

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

Do not run the system if the function evaluates to true.
source§

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

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

System name used in error and gui built for shipyard.
Defaults to the system function name.
source§

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

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

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

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) -> WorkloadSystem
where Self: Sized,

Only run the system if the T storage is empty. Read more
source§

fn run_if_missing_unique<T: Unique>(self) -> WorkloadSystem
where 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) -> WorkloadSystem
where Self: Sized,

Only run the system if the storage is empty. Read more
source§

fn skip_if_storage_empty<T: Component>(self) -> WorkloadSystem
where Self: Sized,

Do not run the system if the T storage is empty. Read more
source§

fn skip_if_missing_unique<T: Unique>(self) -> WorkloadSystem
where 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) -> WorkloadSystem
where Self: Sized,

Do not run the system if the storage is empty. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<Views, R, Sys> AsLabel<(Views, R)> for Sys
where Sys: IntoWorkloadSystem<Views, R> + 'static, R: 'static,

source§

fn as_label(&self) -> Box<dyn Label>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
source§

impl<Views, R, Sys> IntoWorkload<Views, R> for Sys
where Sys: IntoWorkloadSystem<Views, R> + 'static, R: 'static,

source§

fn into_workload(self) -> Workload

Converts to a collection of systems. Read more
source§

fn into_sequential_workload(self) -> Workload

Converts to a collection of systems.
All systems will run one after the other. Does not propagate into nested Workload but they will run sequentially between them. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more