bevy_ecs::system

Trait IntoSystem

Source
pub trait IntoSystem<In: SystemInput, Out, Marker>: Sized {
    type System: System<In = In, Out = Out>;

    // Required method
    fn into_system(this: Self) -> Self::System;

    // Provided methods
    fn pipe<B, BIn, BOut, MarkerB>(self, system: B) -> IntoPipeSystem<Self, B>
       where Out: 'static,
             B: IntoSystem<BIn, BOut, MarkerB>,
             for<'a> BIn: SystemInput<Inner<'a> = Out> { ... }
    fn map<T, F>(self, f: F) -> IntoAdapterSystem<F, Self>
       where F: Send + Sync + 'static + FnMut(Out) -> T { ... }
    fn system_type_id(&self) -> TypeId { ... }
}
Expand description

Conversion trait to turn something into a System.

Use this to get a system from a function. Also note that every system implements this trait as well.

§Examples

use bevy_ecs::prelude::*;

fn my_system_function(a_usize_local: Local<usize>) {}

let system = IntoSystem::into_system(my_system_function);

Required Associated Types§

Source

type System: System<In = In, Out = Out>

The type of System that this instance converts into.

Required Methods§

Source

fn into_system(this: Self) -> Self::System

Turns this value into its corresponding System.

Provided Methods§

Source

fn pipe<B, BIn, BOut, MarkerB>(self, system: B) -> IntoPipeSystem<Self, B>
where Out: 'static, B: IntoSystem<BIn, BOut, MarkerB>, for<'a> BIn: SystemInput<Inner<'a> = Out>,

Pass the output of this system A into a second system B, creating a new compound system.

The second system must have In<T> as its first parameter, where T is the return type of the first system.

Source

fn map<T, F>(self, f: F) -> IntoAdapterSystem<F, Self>
where F: Send + Sync + 'static + FnMut(Out) -> T,

Pass the output of this system into the passed function f, creating a new system that outputs the value returned from the function.

// Ignores the output of a system that may fail.
schedule.add_systems(my_system.map(drop));

fn my_system(res: Res<T>) -> Result<(), Err> {
    // ...
}
Source

fn system_type_id(&self) -> TypeId

Get the TypeId of the System produced after calling into_system.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<A, B, IA, OA, IB, OB, MA, MB> IntoSystem<IA, OB, (IsPipeSystemMarker, OA, IB, MA, MB)> for IntoPipeSystem<A, B>
where IA: SystemInput, A: IntoSystem<IA, OA, MA>, B: IntoSystem<IB, OB, MB>, for<'a> IB: SystemInput<Inner<'a> = OA>,

Source§

type System = PipeSystem<<A as IntoSystem<IA, OA, MA>>::System, <B as IntoSystem<IB, OB, MB>>::System>

Source§

impl<Func, S, I, O, M> IntoSystem<<Func as Adapt<<S as IntoSystem<I, O, M>>::System>>::In, <Func as Adapt<<S as IntoSystem<I, O, M>>::System>>::Out, (IsAdapterSystemMarker, I, O, M)> for IntoAdapterSystem<Func, S>
where Func: Adapt<S::System>, I: SystemInput, S: IntoSystem<I, O, M>,

Source§

type System = AdapterSystem<Func, <S as IntoSystem<I, O, M>>::System>

Source§

impl<Marker, F> IntoSystem<<F as ExclusiveSystemParamFunction<Marker>>::In, <F as ExclusiveSystemParamFunction<Marker>>::Out, (IsExclusiveFunctionSystem, Marker)> for F
where Marker: 'static, F: ExclusiveSystemParamFunction<Marker>,

Source§

impl<Marker, F> IntoSystem<<F as SystemParamFunction<Marker>>::In, <F as SystemParamFunction<Marker>>::Out, (IsFunctionSystem, Marker)> for F
where Marker: 'static, F: SystemParamFunction<Marker>,

Source§

type System = FunctionSystem<Marker, F>

Source§

impl<T: System> IntoSystem<<T as System>::In, <T as System>::Out, ()> for T