bevy_ecs/system/
schedule_system.rs1use alloc::{borrow::Cow, vec::Vec};
2
3use crate::{
4 archetype::ArchetypeComponentId,
5 component::{ComponentId, Tick},
6 error::Result,
7 query::Access,
8 system::{input::SystemIn, BoxedSystem, System},
9 world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World},
10};
11
12use super::{IntoSystem, SystemParamValidationError};
13
14pub struct InfallibleSystemWrapper<S: System<In = ()>>(S);
16
17impl<S: System<In = ()>> InfallibleSystemWrapper<S> {
18 pub fn new(system: S) -> Self {
20 Self(IntoSystem::into_system(system))
21 }
22}
23
24impl<S: System<In = ()>> System for InfallibleSystemWrapper<S> {
25 type In = ();
26 type Out = Result;
27
28 #[inline]
29 fn name(&self) -> Cow<'static, str> {
30 self.0.name()
31 }
32
33 #[inline]
34 fn component_access(&self) -> &Access<ComponentId> {
35 self.0.component_access()
36 }
37
38 #[inline]
39 fn archetype_component_access(&self) -> &Access<ArchetypeComponentId> {
40 self.0.archetype_component_access()
41 }
42
43 #[inline]
44 fn is_send(&self) -> bool {
45 self.0.is_send()
46 }
47
48 #[inline]
49 fn is_exclusive(&self) -> bool {
50 self.0.is_exclusive()
51 }
52
53 #[inline]
54 fn has_deferred(&self) -> bool {
55 self.0.has_deferred()
56 }
57
58 #[inline]
59 unsafe fn run_unsafe(
60 &mut self,
61 input: SystemIn<'_, Self>,
62 world: UnsafeWorldCell,
63 ) -> Self::Out {
64 self.0.run_unsafe(input, world);
65 Ok(())
66 }
67
68 #[inline]
69 fn apply_deferred(&mut self, world: &mut World) {
70 self.0.apply_deferred(world);
71 }
72
73 #[inline]
74 fn queue_deferred(&mut self, world: DeferredWorld) {
75 self.0.queue_deferred(world);
76 }
77
78 #[inline]
79 unsafe fn validate_param_unsafe(
80 &mut self,
81 world: UnsafeWorldCell,
82 ) -> Result<(), SystemParamValidationError> {
83 self.0.validate_param_unsafe(world)
84 }
85
86 #[inline]
87 fn initialize(&mut self, world: &mut World) {
88 self.0.initialize(world);
89 }
90
91 #[inline]
92 fn update_archetype_component_access(&mut self, world: UnsafeWorldCell) {
93 self.0.update_archetype_component_access(world);
94 }
95
96 #[inline]
97 fn check_change_tick(&mut self, change_tick: Tick) {
98 self.0.check_change_tick(change_tick);
99 }
100
101 #[inline]
102 fn get_last_run(&self) -> Tick {
103 self.0.get_last_run()
104 }
105
106 #[inline]
107 fn set_last_run(&mut self, last_run: Tick) {
108 self.0.set_last_run(last_run);
109 }
110
111 fn default_system_sets(&self) -> Vec<crate::schedule::InternedSystemSet> {
112 self.0.default_system_sets()
113 }
114}
115
116pub type ScheduleSystem = BoxedSystem<(), Result>;