Type Alias valence::ecs::system::PipeSystem
pub type PipeSystem<SystemA, SystemB> = CombinatorSystem<Pipe, SystemA, SystemB>;
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)
}
Aliased Type§
struct PipeSystem<SystemA, SystemB> { /* private fields */ }
Implementations
§impl<Func, A, B> CombinatorSystem<Func, A, B>
impl<Func, A, B> CombinatorSystem<Func, A, B>
pub const fn new(
a: A,
b: B,
name: Cow<'static, str>,
) -> CombinatorSystem<Func, A, B>
pub const fn new( a: A, b: B, name: Cow<'static, str>, ) -> CombinatorSystem<Func, A, B>
Creates a new system that combines two inner systems.
The returned system will only be usable if Func
implements Combine<A, B>
.
Trait Implementations
§impl<Func, A, B> Clone for CombinatorSystem<Func, A, B>
impl<Func, A, B> Clone for CombinatorSystem<Func, A, B>
§fn clone(&self) -> CombinatorSystem<Func, A, B>
fn clone(&self) -> CombinatorSystem<Func, A, B>
Clone the combined system. The cloned instance must be .initialize()
d before it can run.
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<A, B, Func> ReadOnlySystem for CombinatorSystem<Func, A, B>
impl<A, B, Func> ReadOnlySystem for CombinatorSystem<Func, A, B>
SAFETY: Both systems are read-only, so any system created by combining them will only read from the world.
§impl<A, B, Func> System for CombinatorSystem<Func, A, B>
impl<A, B, Func> System for CombinatorSystem<Func, A, B>
§fn component_access(&self) -> &Access<ComponentId>
fn component_access(&self) -> &Access<ComponentId>
Access
.§fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>
fn archetype_component_access(&self) -> &Access<ArchetypeComponentId>
Access
.§fn is_exclusive(&self) -> bool
fn is_exclusive(&self) -> bool
§fn has_deferred(&self) -> bool
fn has_deferred(&self) -> bool
§unsafe fn run_unsafe(
&mut self,
input: <CombinatorSystem<Func, A, B> as System>::In,
world: UnsafeWorldCell<'_>,
) -> <CombinatorSystem<Func, A, B> as System>::Out
unsafe fn run_unsafe( &mut self, input: <CombinatorSystem<Func, A, B> as System>::In, world: UnsafeWorldCell<'_>, ) -> <CombinatorSystem<Func, A, B> as System>::Out
System::run
, this function
can be called in parallel with other systems and may break Rust’s aliasing rules
if used incorrectly, making it unsafe to call. Read more§fn run<'w>(
&mut self,
input: <CombinatorSystem<Func, A, B> as System>::In,
world: &'w mut World,
) -> <CombinatorSystem<Func, A, B> as System>::Out
fn run<'w>( &mut self, input: <CombinatorSystem<Func, A, B> as System>::In, world: &'w mut World, ) -> <CombinatorSystem<Func, A, B> as System>::Out
§fn apply_deferred(&mut self, world: &mut World)
fn apply_deferred(&mut self, world: &mut World)
§fn queue_deferred(&mut self, world: DeferredWorld<'_>)
fn queue_deferred(&mut self, world: DeferredWorld<'_>)
Deferred
system parameters (or other system buffers)
of this system into the world’s command buffer.