Struct bevy::ecs::system::PipeSystem
pub struct PipeSystem<SystemA, SystemB> { /* private fields */ }
Expand description
A System
created by piping the output of the first system into the input of the second.
This can be repeated indefinitely, but system pipes cannot branch: the output is consumed by the receiving system.
Given two systems A
and B
, A may be piped into B
as A.pipe(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()));
// pipe the `parse_message_system`'s output into the `filter_system`s input
let mut piped_system = parse_message_system.pipe(filter_system);
piped_system.initialize(&mut world);
assert_eq!(piped_system.run((), &mut world), Some(42));
}
#[derive(Resource)]
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
impl<SystemA, SystemB> System for PipeSystem<SystemA, SystemB>where
SystemA: System,
SystemB: System<In = <SystemA as System>::Out>,
impl<SystemA, SystemB> System for PipeSystem<SystemA, SystemB>where
SystemA: System,
SystemB: System<In = <SystemA as System>::Out>,
fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>
fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>
Returns the system’s archetype component
Access
.fn component_access(&self) -> &Access<ComponentId>
fn component_access(&self) -> &Access<ComponentId>
Returns the system’s component
Access
.fn is_exclusive(&self) -> bool
fn is_exclusive(&self) -> bool
Returns true if the system must be run exclusively.
unsafe fn run_unsafe(
&mut self,
input: <PipeSystem<SystemA, SystemB> as System>::In,
world: &World
) -> <PipeSystem<SystemA, SystemB> as System>::Out
unsafe fn run_unsafe(
&mut self,
input: <PipeSystem<SystemA, SystemB> as System>::In,
world: &World
) -> <PipeSystem<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 morefn apply_buffers(&mut self, world: &mut World)
fn initialize(&mut self, world: &mut World)
fn initialize(&mut self, world: &mut World)
Initialize the system.
fn update_archetype_component_access(&mut self, world: &World)
fn update_archetype_component_access(&mut self, world: &World)
Update the system’s archetype component
Access
.fn check_change_tick(&mut self, change_tick: u32)
fn get_last_change_tick(&self) -> u32
fn get_last_change_tick(&self) -> u32
Gets the system’s last change tick
fn set_last_change_tick(&mut self, last_change_tick: u32)
fn set_last_change_tick(&mut self, last_change_tick: u32)
Sets the system’s last change tick Read more
fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out
fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out
Runs the system with the given input in the world.
fn default_labels(&self) -> Vec<SystemLabelId, Global>ⓘ
fn default_labels(&self) -> Vec<SystemLabelId, Global>ⓘ
The default labels for the system
Auto Trait Implementations
impl<SystemA, SystemB> RefUnwindSafe for PipeSystem<SystemA, SystemB>where
SystemA: RefUnwindSafe,
SystemB: RefUnwindSafe,
impl<SystemA, SystemB> Send for PipeSystem<SystemA, SystemB>where
SystemA: Send,
SystemB: Send,
impl<SystemA, SystemB> Sync for PipeSystem<SystemA, SystemB>where
SystemA: Sync,
SystemB: Sync,
impl<SystemA, SystemB> Unpin for PipeSystem<SystemA, SystemB>where
SystemA: Unpin,
SystemB: Unpin,
impl<SystemA, SystemB> UnwindSafe for PipeSystem<SystemA, SystemB>where
SystemA: UnwindSafe,
SystemB: UnwindSafe,
Blanket Implementations
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist. Read moresourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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 morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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 morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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 moresourceimpl<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<SystemA, ParamA, Payload, SystemB, ParamB, Out> IntoPipeSystem<ParamA, Payload, SystemB, ParamB, Out> for SystemAwhere
SystemA: IntoSystem<(), Payload, ParamA>,
SystemB: IntoSystem<Payload, Out, ParamB>,
impl<SystemA, ParamA, Payload, SystemB, ParamB, Out> IntoPipeSystem<ParamA, Payload, SystemB, ParamB, Out> for SystemAwhere
SystemA: IntoSystem<(), Payload, ParamA>,
SystemB: IntoSystem<Payload, Out, ParamB>,
fn pipe(
self,
system: SystemB
) -> PipeSystem<<SystemA as IntoSystem<(), Payload, ParamA>>::System, <SystemB as IntoSystem<Payload, Out, ParamB>>::System>
fn pipe(
self,
system: SystemB
) -> PipeSystem<<SystemA as IntoSystem<(), Payload, ParamA>>::System, <SystemB as IntoSystem<Payload, Out, ParamB>>::System>
Pass the output of this system
A
into a second system B
, creating a new compound system.impl<S, Param> IntoRunCriteria<(Box<dyn System<In = (), Out = ShouldRun> + 'static, Global>, Param)> for Swhere
S: IntoSystem<(), ShouldRun, Param>,
impl<S, Param> IntoRunCriteria<(Box<dyn System<In = (), Out = ShouldRun> + 'static, Global>, Param)> for Swhere
S: IntoSystem<(), ShouldRun, Param>,
fn into(self) -> RunCriteriaDescriptorOrLabel
impl<In, Out, Sys> IntoSystem<In, Out, AlreadyWasSystem> for Syswhere
Sys: System<In = In, Out = Out>,
impl<In, Out, Sys> IntoSystem<In, Out, AlreadyWasSystem> for Syswhere
Sys: System<In = In, Out = Out>,
type System = Sys
fn into_system(this: Sys) -> Sys
fn into_system(this: Sys) -> Sys
Turns this value into its corresponding
System
.impl<S, Params> IntoSystemDescriptor<Params> for Swhere
S: IntoSystem<(), (), Params>,
impl<S, Params> IntoSystemDescriptor<Params> for Swhere
S: IntoSystem<(), (), Params>,
fn with_run_criteria<Marker>(
self,
run_criteria: impl IntoRunCriteria<Marker>
) -> SystemDescriptor
fn with_run_criteria<Marker>(
self,
run_criteria: impl IntoRunCriteria<Marker>
) -> SystemDescriptor
Assigns a run criteria to the system. Can be a new descriptor or a label of a
run criteria defined elsewhere. Read more
fn label(self, label: impl SystemLabel) -> SystemDescriptor
fn label(self, label: impl SystemLabel) -> SystemDescriptor
Assigns a label to the system; there can be more than one, and it doesn’t have to be unique.
fn before<Marker>(self, label: impl AsSystemLabel<Marker>) -> SystemDescriptor
fn before<Marker>(self, label: impl AsSystemLabel<Marker>) -> SystemDescriptor
Specifies that the system should run before systems with the given label.
fn after<Marker>(self, label: impl AsSystemLabel<Marker>) -> SystemDescriptor
fn after<Marker>(self, label: impl AsSystemLabel<Marker>) -> SystemDescriptor
Specifies that the system should run after systems with the given label.
fn ambiguous_with<Marker>(
self,
label: impl AsSystemLabel<Marker>
) -> SystemDescriptor
fn ambiguous_with<Marker>(
self,
label: impl AsSystemLabel<Marker>
) -> SystemDescriptor
Marks this system as ambiguous with any system with the specified label.
This means that execution order between these systems does not matter,
which allows some warnings to be silenced. Read more
fn ignore_all_ambiguities(self) -> SystemDescriptor
fn ignore_all_ambiguities(self) -> SystemDescriptor
Specifies that this system should opt out of
execution order ambiguity detection. Read more
fn at_start(self) -> SystemDescriptor
fn at_start(self) -> SystemDescriptor
Specifies that the system should run with other exclusive systems at the start of stage.
fn before_commands(self) -> SystemDescriptor
fn before_commands(self) -> SystemDescriptor
Specifies that the system should run with other exclusive systems after the parallel
systems and before command buffer application. Read more
fn at_end(self) -> SystemDescriptor
fn at_end(self) -> SystemDescriptor
Specifies that the system should run with other exclusive systems at the end of stage.
fn into_descriptor(self) -> SystemDescriptor
impl<S, Param> RunCriteriaDescriptorCoercion<Param> for Swhere
S: IntoSystem<(), ShouldRun, Param>,
impl<S, Param> RunCriteriaDescriptorCoercion<Param> for Swhere
S: IntoSystem<(), ShouldRun, Param>,
fn label(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
fn label(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
Assigns a label to the criteria. Must be unique.
fn label_discard_if_duplicate(
self,
label: impl RunCriteriaLabel
) -> RunCriteriaDescriptor
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
fn before(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
fn before(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
Specifies that this criteria must be evaluated before a criteria with the given label.
fn after(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
fn after(self, label: impl RunCriteriaLabel) -> RunCriteriaDescriptor
Specifies that this criteria must be evaluated after a criteria with the given label.