Struct bevy::ecs::system::ChainSystem [−]
pub struct ChainSystem<SystemA, SystemB> { /* fields omitted */ }
Expand description
A System
that chains two systems together, creating a new system that routes the output of
the first system into the input of the second system, yielding the output of the second system.
Given two systems A and B, A may be chained with B as A.chain(B)
if the output type of A is
equal to the input type of B.
Note that for FunctionSystem
s the output is the return value
of the function and the input is the first SystemParam
if it is
tagged with In
or ()
if the function has no designated input parameter.
Examples
use std::num::ParseIntError;
use bevy_ecs::prelude::*;
fn main() {
let mut world = World::default();
world.insert_resource(Message("42".to_string()));
// chain the `parse_message_system`'s output into the `filter_system`s input
let mut chained_system = parse_message_system.chain(filter_system);
chained_system.initialize(&mut world);
assert_eq!(chained_system.run((), &mut world), Some(42));
}
struct Message(String);
fn parse_message_system(message: Res<Message>) -> Result<usize, ParseIntError> {
message.0.parse::<usize>()
}
fn filter_system(In(result): In<Result<usize, ParseIntError>>) -> Option<usize> {
result.ok().filter(|&n| n < 100)
}
Trait Implementations
pub fn new_archetype(&mut self, archetype: &Archetype)
pub fn new_archetype(&mut self, archetype: &Archetype)
Register a new archetype for this system.
pub fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>
pub fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>
Returns the system’s archetype component Access
.
pub fn component_access(&self) -> &Access<ComponentId>
pub fn component_access(&self) -> &Access<ComponentId>
Returns the system’s component Access
.
pub unsafe fn run_unsafe(
&mut self,
input: <ChainSystem<SystemA, SystemB> as System>::In,
world: &World
) -> <ChainSystem<SystemA, SystemB> as System>::Out
pub unsafe fn run_unsafe(
&mut self,
input: <ChainSystem<SystemA, SystemB> as System>::In,
world: &World
) -> <ChainSystem<SystemA, SystemB> as System>::Out
Runs the system with the given input in the world. Unlike System::run
, this function
takes a shared reference to World
and may therefore break Rust’s aliasing rules, making
it unsafe to call. Read more
pub fn apply_buffers(&mut self, world: &mut World)
pub fn initialize(&mut self, world: &mut World)
pub fn initialize(&mut self, world: &mut World)
Initialize the system.
pub fn check_change_tick(&mut self, change_tick: u32)
Auto Trait Implementations
impl<SystemA, SystemB> RefUnwindSafe for ChainSystem<SystemA, SystemB> where
SystemA: RefUnwindSafe,
SystemB: RefUnwindSafe,
impl<SystemA, SystemB> Send for ChainSystem<SystemA, SystemB> where
SystemA: Send,
SystemB: Send,
impl<SystemA, SystemB> Sync for ChainSystem<SystemA, SystemB> where
SystemA: Sync,
SystemB: Sync,
impl<SystemA, SystemB> Unpin for ChainSystem<SystemA, SystemB> where
SystemA: Unpin,
SystemB: Unpin,
impl<SystemA, SystemB> UnwindSafe for ChainSystem<SystemA, SystemB> where
SystemA: UnwindSafe,
SystemB: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<SystemA, ParamA, Payload, SystemB, ParamB, Out> IntoChainSystem<ParamA, Payload, SystemB, ParamB, Out> for SystemA where
SystemA: IntoSystem<(), Payload, ParamA>,
SystemB: IntoSystem<Payload, Out, ParamB>,
impl<SystemA, ParamA, Payload, SystemB, ParamB, Out> IntoChainSystem<ParamA, Payload, SystemB, ParamB, Out> for SystemA where
SystemA: IntoSystem<(), Payload, ParamA>,
SystemB: IntoSystem<Payload, Out, ParamB>,
pub fn chain(
self,
system: SystemB
) -> ChainSystem<<SystemA as IntoSystem<(), Payload, ParamA>>::System, <SystemB as IntoSystem<Payload, Out, ParamB>>::System>
pub fn chain(
self,
system: SystemB
) -> ChainSystem<<SystemA as IntoSystem<(), Payload, ParamA>>::System, <SystemB as IntoSystem<Payload, Out, ParamB>>::System>
Chain this system A
with another system B
creating a new system that feeds system A’s
output into system B
, returning the output of system B
. Read more
impl<S, Params> IntoExclusiveSystem<Params, ExclusiveSystemCoerced> for S where
S: IntoSystem<(), (), Params>,
impl<S, Params> IntoExclusiveSystem<Params, ExclusiveSystemCoerced> for S where
S: IntoSystem<(), (), Params>,
pub fn exclusive_system(self) -> ExclusiveSystemCoerced
pub fn into(self) -> RunCriteriaDescriptorOrLabel
impl<In, Out, Sys> IntoSystem<In, Out, AlreadyWasSystem> for Sys where
Sys: System<In = In, Out = Out>,
impl<In, Out, Sys> IntoSystem<In, Out, AlreadyWasSystem> for Sys where
Sys: System<In = In, Out = Out>,
impl<Params, S> IntoSystemDescriptor<Params> for S where
S: IntoSystem<(), (), Params>,
impl<Params, S> IntoSystemDescriptor<Params> for S where
S: IntoSystem<(), (), Params>,
pub fn into_descriptor(self) -> SystemDescriptor
impl<S, Params> ParallelSystemDescriptorCoercion<Params> for S where
S: IntoSystem<(), (), Params>,
impl<S, Params> ParallelSystemDescriptorCoercion<Params> for S where
S: IntoSystem<(), (), Params>,
pub fn with_run_criteria<Marker>(
self,
run_criteria: impl IntoRunCriteria<Marker>
) -> ParallelSystemDescriptor
pub fn with_run_criteria<Marker>(
self,
run_criteria: impl IntoRunCriteria<Marker>
) -> ParallelSystemDescriptor
Assigns a run criteria to the system. Can be a new descriptor or a label of a run criteria defined elsewhere. Read more
pub fn label(self, label: impl SystemLabel) -> ParallelSystemDescriptor
pub fn label(self, label: impl SystemLabel) -> ParallelSystemDescriptor
Assigns a label to the system; there can be more than one, and it doesn’t have to be unique.
pub fn before(self, label: impl SystemLabel) -> ParallelSystemDescriptor
pub fn before(self, label: impl SystemLabel) -> ParallelSystemDescriptor
Specifies that the system should run before systems with the given label.
pub fn after(self, label: impl SystemLabel) -> ParallelSystemDescriptor
pub fn after(self, label: impl SystemLabel) -> ParallelSystemDescriptor
Specifies that the system should run after systems with the given label.
pub fn in_ambiguity_set(
self,
set: impl AmbiguitySetLabel
) -> ParallelSystemDescriptor
pub fn in_ambiguity_set(
self,
set: impl AmbiguitySetLabel
) -> ParallelSystemDescriptor
Specifies that the system is exempt from execution order ambiguity detection with other systems in this set. Read more
impl<S, Param> RunCriteriaDescriptorCoercion<Param> for S where
S: IntoSystem<(), ShouldRun, Param>,
impl<S, Param> RunCriteriaDescriptorCoercion<Param> for S where
S: IntoSystem<(), ShouldRun, Param>,
pub fn label(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
pub fn label(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
Assigns a label to the criteria. Must be unique.
pub fn label_discard_if_duplicate(
self,
label: impl RunCriteriaLabel
) -> RunCriteriaDescriptor
pub fn label_discard_if_duplicate(
self,
label: impl RunCriteriaLabel
) -> RunCriteriaDescriptor
Assigns a label to the criteria. If the given label is already in use, this criteria will be discarded before initialization. Read more
pub fn before(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
pub fn before(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
Specifies that this criteria must be evaluated before a criteria with the given label.
pub fn after(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
pub fn after(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
Specifies that this criteria must be evaluated after a criteria with the given label.
pub fn vzip(self) -> V
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more