Skip to main content

SubApp

Struct SubApp 

Source
pub struct SubApp {
    pub update_schedule: Option<Interned<dyn ScheduleLabel>>,
    /* private fields */
}
Expand description

A secondary application with its own World. These can run independently of each other.

These are useful for situations where certain processes (e.g. a render thread) need to be kept separate from the main application.

§Example


#[derive(Resource, Default)]
struct Val(pub i32);

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, AppLabel)]
struct ExampleApp;

// Create an app with a certain resource.
let mut app = App::new();
app.insert_resource(Val(10));

// Create a sub-app with the same resource and a single schedule.
let mut sub_app = SubApp::new();
sub_app.update_schedule = Some(Main.intern());
sub_app.insert_resource(Val(100));

// Setup an extract function to copy the resource's value in the main world.
sub_app.set_extract(|main_world, sub_world| {
    sub_world.resource_mut::<Val>().0 = main_world.resource::<Val>().0;
});

// Schedule a system that will verify extraction is working.
sub_app.add_systems(Main, |counter: Res<Val>| {
    // The value will be copied during extraction, so we should see 10 instead of 100.
    assert_eq!(counter.0, 10);
});

// Add the sub-app to the main app.
app.insert_sub_app(ExampleApp, sub_app);

// Update the application once (using the default runner).
app.run();

Fields§

§update_schedule: Option<Interned<dyn ScheduleLabel>>

The schedule that will be run by update.

Implementations§

Source§

impl SubApp

Source

pub fn new() -> SubApp

Returns a default, empty SubApp.

Source

pub fn world(&self) -> &World

Returns a reference to the World.

Examples found in repository?
examples/app/externally_driven_headless_renderer.rs (line 110)
105    fn update(&mut self) {
106        self.0.update();
107        // Wait for frame to finish rendering by wait polling the device
108        self.0
109            .main
110            .world()
111            .resource::<RenderDevice>()
112            .wgpu_device()
113            .poll(PollType::Wait {
114                submission_index: None,
115                timeout: None,
116            })
117            .unwrap();
118    }
More examples
Hide additional examples
tests/ecs/ambiguity_detection.rs (line 93)
91fn count_ambiguities(sub_app: &mut SubApp) -> AmbiguitiesCount {
92    let schedule_labels = sub_app
93        .world()
94        .resource::<Schedules>()
95        .iter()
96        .map(|(_, schedule)| schedule.label())
97        .collect::<Vec<_>>();
98    let mut ambiguities = <HashMap<_, _>>::default();
99    for label in schedule_labels {
100        let ambiguities_in_schedule =
101            sub_app
102                .world_mut()
103                .schedule_scope(label, |world, schedule| {
104                    schedule.initialize(world).unwrap().unwrap();
105                    schedule.graph().conflicting_systems().len()
106                });
107        ambiguities.insert(label, ambiguities_in_schedule);
108    }
109    AmbiguitiesCount(ambiguities)
110}
Source

pub fn world_mut(&mut self) -> &mut World

Returns a mutable reference to the World.

Examples found in repository?
examples/shader_advanced/compute_mesh.rs (line 67)
62    fn finish(&self, app: &mut App) {
63        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
64            return;
65        };
66        render_app
67            .world_mut()
68            .resource_mut::<MeshAllocatorSettings>()
69            // This allows using the mesh allocator slabs as
70            // storage buffers directly in the compute shader.
71            // Which means that we can write from our compute
72            // shader directly to the allocated mesh slabs.
73            .extra_buffer_usages = BufferUsages::STORAGE;
74    }
More examples
Hide additional examples
examples/app/externally_driven_headless_renderer.rs (line 90)
75    fn new_render_target(&mut self, width: u32, height: u32) -> RenderTarget {
76        let mut target = Image::new_uninit(
77            Extent3d {
78                width,
79                height,
80                depth_or_array_layers: 1,
81            },
82            TextureDimension::D2,
83            TextureFormat::Rgba8UnormSrgb,
84            RenderAssetUsages::RENDER_WORLD,
85        );
86        // We're going to render to this image, mark it as such
87        target.texture_descriptor.usage |= TextureUsages::RENDER_ATTACHMENT;
88        self.0
89            .main
90            .world_mut()
91            .resource_mut::<Assets<Image>>()
92            .add(target)
93            .into()
94    }
95
96    fn spawn_camera(&mut self, target: RenderTarget) -> Entity {
97        self.0
98            .main
99            .world_mut()
100            .spawn((Camera3d::default(), target, Transform::IDENTITY))
101            .id()
102    }
103
104    // Run one world update and wait for rendering to finish.
105    fn update(&mut self) {
106        self.0.update();
107        // Wait for frame to finish rendering by wait polling the device
108        self.0
109            .main
110            .world()
111            .resource::<RenderDevice>()
112            .wgpu_device()
113            .poll(PollType::Wait {
114                submission_index: None,
115                timeout: None,
116            })
117            .unwrap();
118    }
119
120    // Schedules a screenshot to be captured on the next update.
121    fn screenshot(&mut self, target: RenderTarget, i: u32) {
122        self.0
123            .main
124            .world_mut()
125            .spawn(Screenshot::image(target.as_image().unwrap().clone()))
126            .observe(save_to_disk(format!("test_images/screenshot{i}.png")));
127    }
tests/ecs/ambiguity_detection.rs (line 71)
70fn configure_ambiguity_detection(sub_app: &mut SubApp) {
71    let mut schedules = sub_app.world_mut().resource_mut::<Schedules>();
72    for (_, schedule) in schedules.iter_mut() {
73        schedule.set_build_settings(ScheduleBuildSettings {
74            // NOTE: you can change this to `LogLevel::Ignore` to easily see the current number of ambiguities.
75            ambiguity_detection: LogLevel::Warn,
76            // With auto-inserted apply_deferred stages, these can cause two ambiguous systems to
77            // become accidentally ordered by one of the apply_deferred stages. Disabling requires
78            // us to meet a higher bar. We don't just want no ambiguities - we also don't want
79            // changes to systems or the auto-insert code from "creating" new ambiguities (by
80            // reordering the graph). However, the cost is that the graph is no longer runnable,
81            // since Bevy crates often rely on auto-insert apply_deferred to not panic (e.g.,
82            // because a resource wasn't inserted).
83            auto_insert_apply_deferred: false,
84            use_shortnames: false,
85            ..default()
86        });
87    }
88}
89
90/// Returns the number of conflicting systems per schedule.
91fn count_ambiguities(sub_app: &mut SubApp) -> AmbiguitiesCount {
92    let schedule_labels = sub_app
93        .world()
94        .resource::<Schedules>()
95        .iter()
96        .map(|(_, schedule)| schedule.label())
97        .collect::<Vec<_>>();
98    let mut ambiguities = <HashMap<_, _>>::default();
99    for label in schedule_labels {
100        let ambiguities_in_schedule =
101            sub_app
102                .world_mut()
103                .schedule_scope(label, |world, schedule| {
104                    schedule.initialize(world).unwrap().unwrap();
105                    schedule.graph().conflicting_systems().len()
106                });
107        ambiguities.insert(label, ambiguities_in_schedule);
108    }
109    AmbiguitiesCount(ambiguities)
110}
Source

pub fn run_default_schedule(&mut self)

Runs the default schedule.

Does not clear internal trackers used for change detection.

Source

pub fn update(&mut self)

Runs the default schedule and updates internal component trackers.

Source

pub fn extract(&mut self, world: &mut World)

Extracts data from world into the app’s world using the registered extract method.

Note: There is no default extract method. Calling extract does nothing if set_extract has not been called.

Source

pub fn set_extract<F>(&mut self, extract: F) -> &mut SubApp
where F: FnMut(&mut World, &mut World) + Send + 'static,

Sets the method that will be called by extract.

The first argument is the World to extract data from, the second argument is the app World.

Source

pub fn take_extract( &mut self, ) -> Option<Box<dyn FnMut(&mut World, &mut World) + Send>>

Take the function that will be called by extract out of the app, if any was set, and replace it with None.

If you use Bevy, bevy_render will set a default extract function used to extract data from the main world into the render world as part of the Extract phase. In that case, you cannot replace it with your own function. Instead, take the Bevy default function with this, and install your own instead which calls the Bevy default.

let mut default_fn = app.take_extract();
app.set_extract(move |main, render| {
    // Do pre-extract custom logic
    // [...]

    // Call Bevy's default, which executes the Extract phase
    if let Some(f) = default_fn.as_mut() {
        f(main, render);
    }

    // Do post-extract custom logic
    // [...]
});
Source

pub fn insert_resource<R>(&mut self, resource: R) -> &mut SubApp
where R: Resource,

Examples found in repository?
examples/app/headless_renderer.rs (line 213)
205    fn build(&self, app: &mut App) {
206        let (s, r) = crossbeam_channel::unbounded();
207
208        let render_app = app
209            .insert_resource(MainWorldReceiver(r))
210            .sub_app_mut(RenderApp);
211
212        render_app
213            .insert_resource(RenderWorldSender(s))
214            // Make ImageCopiers accessible in RenderWorld system and plugin
215            .add_systems(ExtractSchedule, image_copy_extract)
216            // Receives image data from buffer to channel
217            // so we need to run it after the render graph is done
218            .add_systems(
219                Render,
220                receive_image_from_buffer.after(RenderSystems::Render),
221            )
222            .add_systems(RenderGraph, image_copy_driver);
223    }
More examples
Hide additional examples
examples/ecs/extraction.rs (line 66)
46fn main() {
47    let mut app = App::new();
48
49    // Main World
50    app.insert_resource(WorldName("Main World".into()))
51        .add_plugins((
52            DefaultPlugins,
53            // Plugin for automatically extracting A.
54            ExtractComponentPlugin::<A>::default(),
55        ))
56        .add_message::<ExtractMessage>()
57        .add_systems(Startup, setup)
58        .add_systems(Update, (set_time, trigger_extraction, display_state));
59
60    let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
61        return;
62    };
63
64    // Render World
65    render_app
66        .insert_resource(WorldName("Render World".into()))
67        .add_systems(ExtractSchedule, extract_components)
68        .add_systems(Render, display_state);
69
70    app.run();
71}
examples/2d/mesh2d_manual.rs (line 312)
300    fn build(&self, app: &mut App) {
301        // Load our custom shader
302        let mut shaders = app.world_mut().resource_mut::<Assets<Shader>>();
303        // Here, we construct and add the shader asset manually. There are many ways to load this
304        // shader, including `embedded_asset`/`load_embedded_asset`.
305        let shader = shaders.add(Shader::from_wgsl(COLORED_MESH2D_SHADER, file!()));
306
307        app.add_plugins(SyncComponentPlugin::<ColoredMesh2d>::default());
308
309        // Register our custom draw function, and add our render systems
310        app.get_sub_app_mut(RenderApp)
311            .unwrap()
312            .insert_resource(ColoredMesh2dShader(shader))
313            .add_render_command::<Transparent2d, DrawColoredMesh2d>()
314            .init_resource::<SpecializedRenderPipelines<ColoredMesh2dPipeline>>()
315            .init_resource::<RenderColoredMesh2dInstances>()
316            .add_systems(
317                RenderStartup,
318                init_colored_mesh_2d_pipeline.after(init_mesh_2d_pipeline),
319            )
320            .add_systems(
321                ExtractSchedule,
322                extract_colored_mesh2d.after(extract_mesh2d),
323            )
324            .add_systems(
325                Render,
326                queue_colored_mesh2d.in_set(RenderSystems::QueueMeshes),
327            );
328    }
examples/3d/occlusion_culling.rs (line 214)
197    fn build(&self, app: &mut App) {
198        // Create the `SavedIndirectParameters` resource that we're going to use
199        // to communicate between the thread that the GPU-to-CPU readback
200        // callback runs on and the main application threads. This resource is
201        // atomically reference counted. We store one reference to the
202        // `SavedIndirectParameters` in the main app and another reference in
203        // the render app.
204        let saved_indirect_parameters = SavedIndirectParameters::new();
205        app.insert_resource(saved_indirect_parameters.clone());
206
207        // Fetch the render app.
208        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
209            return;
210        };
211
212        render_app
213            // Insert another reference to the `SavedIndirectParameters`.
214            .insert_resource(saved_indirect_parameters)
215            // Setup the parameters in RenderStartup.
216            .add_systems(RenderStartup, init_saved_indirect_parameters)
217            .init_resource::<IndirectParametersStagingBuffers>()
218            .add_systems(ExtractSchedule, readback_indirect_parameters)
219            .add_systems(
220                Render,
221                create_indirect_parameters_staging_buffers
222                    .in_set(RenderSystems::PrepareResourcesFlush),
223            )
224            .add_systems(
225                Core3d,
226                // Add the node that allows us to read the indirect parameters back
227                // from the GPU to the CPU, which allows us to determine how many
228                // meshes were culled.
229                readback_indirect_parameters_node
230                    // We read back the indirect parameters any time after
231                    // `MainPass`. Readback doesn't particularly need to execute
232                    // before PostProcess, but we order it that way anyway.
233                    .after(Core3dSystems::MainPass)
234                    .before(Core3dSystems::PostProcess),
235            );
236    }
Source

pub fn init_resource<R>(&mut self) -> &mut SubApp
where R: Resource + FromWorld,

Examples found in repository?
examples/shader_advanced/compute_mesh.rs (line 57)
51    fn build(&self, app: &mut App) {
52        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
53            return;
54        };
55
56        render_app
57            .init_resource::<ChunksToProcess>()
58            .add_systems(RenderStartup, init_compute_pipeline)
59            .add_systems(Render, prepare_chunks)
60            .add_systems(RenderGraph, compute_mesh.before(camera_driver));
61    }
More examples
Hide additional examples
examples/shader_advanced/custom_shader_instancing.rs (line 114)
110    fn build(&self, app: &mut App) {
111        app.add_plugins(ExtractComponentPlugin::<InstanceMaterialData>::default());
112        app.sub_app_mut(RenderApp)
113            .add_render_command::<Transparent3d, DrawCustom>()
114            .init_resource::<SpecializedMeshPipelines<CustomPipeline>>()
115            .add_systems(
116                RenderStartup,
117                init_custom_pipeline.after(MeshPipelineSystems),
118            )
119            .add_systems(
120                Render,
121                (
122                    queue_custom.in_set(RenderSystems::QueueMeshes),
123                    prepare_instance_buffers.in_set(RenderSystems::PrepareResources),
124                ),
125            );
126    }
examples/shader_advanced/custom_phase_item.rs (line 172)
164fn main() {
165    let mut app = App::new();
166    app.add_plugins(DefaultPlugins)
167        .add_plugins(ExtractComponentPlugin::<CustomRenderedEntity>::default())
168        .add_systems(Startup, setup);
169
170    // We make sure to add these to the render app, not the main app.
171    app.sub_app_mut(RenderApp)
172        .init_resource::<CustomPhasePipeline>()
173        .init_resource::<PendingCustomPhaseItemQueues>()
174        .add_render_command::<Opaque3d, DrawCustomPhaseItemCommands>()
175        .add_systems(
176            Render,
177            prepare_custom_phase_item_buffers.in_set(RenderSystems::Prepare),
178        )
179        .add_systems(Render, queue_custom_phase_item.in_set(RenderSystems::Queue));
180
181    app.run();
182}
examples/shader/compute_shader_game_of_life.rs (line 103)
94    fn build(&self, app: &mut App) {
95        // Extract the game of life image resource from the main world into the render world
96        // for operation on by the compute shader and display on the sprite.
97        app.add_plugins((
98            ExtractResourcePlugin::<GameOfLifeImages>::default(),
99            ExtractResourcePlugin::<GameOfLifeUniforms>::default(),
100        ));
101        let render_app = app.sub_app_mut(RenderApp);
102        render_app
103            .init_resource::<GameOfLifeState>()
104            .add_systems(RenderStartup, init_game_of_life_pipeline)
105            .add_systems(
106                Render,
107                prepare_bind_group.in_set(RenderSystems::PrepareBindGroups),
108            )
109            .add_systems(Render, update.in_set(RenderSystems::Prepare))
110            .add_systems(RenderGraph, game_of_life.before(camera_driver));
111    }
examples/shader_advanced/specialized_mesh_pipeline.rs (line 115)
106    fn build(&self, app: &mut App) {
107        app.add_plugins(ExtractComponentPlugin::<CustomRenderedEntity>::default());
108
109        // We make sure to add these to the render app, not the main app.
110        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
111            return;
112        };
113        render_app
114            // This is needed to tell bevy about your custom pipeline
115            .init_resource::<SpecializedMeshPipelines<CustomMeshPipeline>>()
116            .init_resource::<PendingCustomMeshQueues>()
117            // We need to use a custom draw command so we need to register it
118            .add_render_command::<Opaque3d, DrawSpecializedPipelineCommands>()
119            .add_systems(
120                RenderStartup,
121                init_custom_mesh_pipeline.after(MeshPipelineSystems),
122            )
123            .add_systems(
124                Render,
125                queue_custom_mesh_pipeline.in_set(RenderSystems::Queue),
126            );
127    }
examples/2d/mesh2d_manual.rs (line 314)
300    fn build(&self, app: &mut App) {
301        // Load our custom shader
302        let mut shaders = app.world_mut().resource_mut::<Assets<Shader>>();
303        // Here, we construct and add the shader asset manually. There are many ways to load this
304        // shader, including `embedded_asset`/`load_embedded_asset`.
305        let shader = shaders.add(Shader::from_wgsl(COLORED_MESH2D_SHADER, file!()));
306
307        app.add_plugins(SyncComponentPlugin::<ColoredMesh2d>::default());
308
309        // Register our custom draw function, and add our render systems
310        app.get_sub_app_mut(RenderApp)
311            .unwrap()
312            .insert_resource(ColoredMesh2dShader(shader))
313            .add_render_command::<Transparent2d, DrawColoredMesh2d>()
314            .init_resource::<SpecializedRenderPipelines<ColoredMesh2dPipeline>>()
315            .init_resource::<RenderColoredMesh2dInstances>()
316            .add_systems(
317                RenderStartup,
318                init_colored_mesh_2d_pipeline.after(init_mesh_2d_pipeline),
319            )
320            .add_systems(
321                ExtractSchedule,
322                extract_colored_mesh2d.after(extract_mesh2d),
323            )
324            .add_systems(
325                Render,
326                queue_colored_mesh2d.in_set(RenderSystems::QueueMeshes),
327            );
328    }
Source

pub fn add_systems<M>( &mut self, schedule: impl ScheduleLabel, systems: impl IntoScheduleConfigs<Box<dyn System<Out = (), In = ()>>, M>, ) -> &mut SubApp

Examples found in repository?
examples/shader_advanced/texture_binding_array.rs (line 49)
44    fn build(&self, app: &mut App) {
45        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
46            return;
47        };
48
49        render_app.add_systems(RenderStartup, verify_required_features);
50    }
More examples
Hide additional examples
examples/stress_tests/many_lights.rs (lines 158-161)
153    fn build(&self, app: &mut App) {
154        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
155            return;
156        };
157
158        render_app.add_systems(
159            Render,
160            print_visible_light_count.in_set(RenderSystems::Prepare),
161        );
162    }
examples/app/render_recovery.rs (line 30)
20fn main() {
21    let mut app = App::new();
22    app.add_plugins((
23        DefaultPlugins,
24        ExtractResourcePlugin::<RenderError>::default(),
25    ))
26    .add_systems(Startup, setup)
27    .add_systems(Update, (update_camera, input))
28    .init_resource::<RenderError>()
29    .sub_app_mut(RenderApp)
30    .add_systems(Render, cause_error);
31    app.run();
32}
examples/shader_advanced/compute_mesh.rs (line 58)
51    fn build(&self, app: &mut App) {
52        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
53            return;
54        };
55
56        render_app
57            .init_resource::<ChunksToProcess>()
58            .add_systems(RenderStartup, init_compute_pipeline)
59            .add_systems(Render, prepare_chunks)
60            .add_systems(RenderGraph, compute_mesh.before(camera_driver));
61    }
examples/showcase/loading_screen.rs (line 293)
284        fn build(&self, app: &mut App) {
285            app.insert_resource(PipelinesReady::default());
286
287            // In order to gain access to the pipelines status, we have to
288            // go into the `RenderApp`, grab the resource from the main App
289            // and then update the pipelines status from there.
290            // Writing between these Apps can only be done through the
291            // `ExtractSchedule`.
292            app.sub_app_mut(RenderApp)
293                .add_systems(ExtractSchedule, update_pipelines_ready);
294        }
examples/shader/gpu_readback.rs (line 49)
44    fn build(&self, app: &mut App) {
45        let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
46            return;
47        };
48        render_app
49            .add_systems(RenderStartup, init_compute_pipeline)
50            .add_systems(
51                Render,
52                prepare_bind_group
53                    .in_set(RenderSystems::PrepareBindGroups)
54                    // We don't need to recreate the bind group every frame
55                    .run_if(not(resource_exists::<GpuBufferBindGroup>)),
56            )
57            .add_systems(RenderGraph, compute);
58    }
Source

pub fn remove_systems_in_set<M>( &mut self, schedule: impl ScheduleLabel, set: impl IntoSystemSet<M>, policy: ScheduleCleanupPolicy, ) -> Result<usize, ScheduleError>

Source

pub fn register_system<I, O, M>( &mut self, system: impl IntoSystem<I, O, M> + 'static, ) -> SystemId<I, O>
where I: SystemInput + 'static, O: 'static,

Source

pub fn register_tracked_system<I, O, M>( &mut self, system: impl IntoSystem<I, O, M> + 'static, ) -> SystemHandle<I, O>
where I: SystemInput + 'static, O: 'static,

Source

pub fn configure_sets<M>( &mut self, schedule: impl ScheduleLabel, sets: impl IntoScheduleConfigs<Interned<dyn SystemSet>, M>, ) -> &mut SubApp

Source

pub fn add_schedule(&mut self, schedule: Schedule) -> &mut SubApp

Source

pub fn init_schedule(&mut self, label: impl ScheduleLabel) -> &mut SubApp

Source

pub fn get_schedule(&self, label: impl ScheduleLabel) -> Option<&Schedule>

Source

pub fn get_schedule_mut( &mut self, label: impl ScheduleLabel, ) -> Option<&mut Schedule>

Source

pub fn edit_schedule( &mut self, label: impl ScheduleLabel, f: impl FnMut(&mut Schedule), ) -> &mut SubApp

Source

pub fn configure_schedules( &mut self, schedule_build_settings: ScheduleBuildSettings, ) -> &mut SubApp

Source

pub fn allow_ambiguous_component<T>(&mut self) -> &mut SubApp
where T: Component,

Source

pub fn allow_ambiguous_resource<T>(&mut self) -> &mut SubApp
where T: Resource,

Source

pub fn ignore_ambiguity<M1, M2, S1, S2>( &mut self, schedule: impl ScheduleLabel, a: S1, b: S2, ) -> &mut SubApp
where S1: IntoSystemSet<M1>, S2: IntoSystemSet<M2>,

Source

pub fn add_observer<M>(&mut self, observer: impl IntoObserver<M>) -> &mut SubApp

Source

pub fn add_message<T>(&mut self) -> &mut SubApp
where T: Message,

Source

pub fn add_plugins<M>(&mut self, plugins: impl Plugins<M>) -> &mut SubApp

Source

pub fn is_plugin_added<T>(&self) -> bool
where T: Plugin,

Source

pub fn get_added_plugins<T>(&self) -> Vec<&T>
where T: Plugin,

Source

pub fn plugins_state(&mut self) -> PluginsState

Return the state of plugins.

Source

pub fn finish(&mut self)

Runs Plugin::finish for each plugin.

Source

pub fn cleanup(&mut self)

Runs Plugin::cleanup for each plugin.

Source

pub fn register_type<T>(&mut self) -> &mut SubApp

Available on crate feature bevy_reflect only.
Source

pub fn register_type_data<T, D>(&mut self) -> &mut SubApp
where T: Reflect + TypePath, D: TypeData + FromType<T>,

Available on crate feature bevy_reflect only.
Source

pub fn register_type_conversion<T, U, F>(&mut self, function: F) -> &mut SubApp
where T: Reflect + TypePath, U: Reflect + TypePath, F: Fn(T) -> Result<U, T> + Clone + Send + Sync + 'static,

Available on crate feature bevy_reflect only.
Source

pub fn register_into_type_conversion<T, U>(&mut self) -> &mut SubApp
where T: Reflect + TypePath, U: Reflect + TypePath + From<T>,

Available on crate feature bevy_reflect only.
Source

pub fn register_function<F, Marker>(&mut self, function: F) -> &mut SubApp
where F: IntoFunction<'static, Marker> + 'static,

Available on crate feature reflect_functions only.
Source

pub fn register_function_with_name<F, Marker>( &mut self, name: impl Into<Cow<'static, str>>, function: F, ) -> &mut SubApp
where F: IntoFunction<'static, Marker> + 'static,

Available on crate feature reflect_functions only.

Trait Implementations§

Source§

impl AddRenderCommand for SubApp

Source§

fn add_render_command<P, C>(&mut self) -> &mut SubApp
where P: PhaseItem, C: RenderCommand<P> + Send + Sync + 'static, <C as RenderCommand<P>>::Param: ReadOnlySystemParam,

Adds the RenderCommand for the specified render phase to the app.
Source§

impl AppExtStates for SubApp

Source§

fn init_state<S>(&mut self) -> &mut SubApp

Initializes a State with standard starting values. Read more
Source§

fn insert_state<S>(&mut self, state: S) -> &mut SubApp

Inserts a specific State to the current App and overrides any State previously added of the same type. Read more
Source§

fn add_computed_state<S>(&mut self) -> &mut SubApp
where S: ComputedStates,

Sets up a type implementing ComputedStates. Read more
Source§

fn add_sub_state<S>(&mut self) -> &mut SubApp
where S: SubStates,

Sets up a type implementing SubStates. Read more
Source§

fn register_type_state<S>(&mut self) -> &mut SubApp

Available on crate feature bevy_reflect only.
Registers the state type T using App::register_type, and adds ReflectState type data to T in the type registry. Read more
Source§

fn register_type_mutable_state<S>(&mut self) -> &mut SubApp

Available on crate feature bevy_reflect only.
Registers the state type T using App::register_type, and adds crate::reflect::ReflectState and crate::reflect::ReflectFreelyMutableState type data to T in the type registry. Read more
Source§

impl Debug for SubApp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SubApp

Source§

fn default() -> SubApp

Returns the “default value” for a type. Read more
Source§

impl GpuResourceAppExt for SubApp

Source§

fn init_gpu_resource<R>(&mut self) -> &mut SubApp
where R: Resource + FromWorld,

Causes the provided GPU resource to be re-initialized during RenderStartup. Read more
Source§

impl RegisterDiagnostic for SubApp

Source§

fn register_diagnostic(&mut self, diagnostic: Diagnostic) -> &mut SubApp

Register a new Diagnostic with an App. Read more
Source§

impl StateScopedMessagesAppExt for SubApp

Source§

fn clear_messages_on_exit<M>(&mut self, state: impl States) -> &mut SubApp
where M: Message,

Clears a Message when exiting the specified state. Read more
Source§

fn clear_messages_on_enter<M>(&mut self, state: impl States) -> &mut SubApp
where M: Message,

Clears a Message when entering the specified state. Read more

Auto Trait Implementations§

§

impl !Freeze for SubApp

§

impl !RefUnwindSafe for SubApp

§

impl !Sync for SubApp

§

impl !UnwindSafe for SubApp

§

impl Send for SubApp

§

impl Unpin for SubApp

§

impl UnsafeUnpin for SubApp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

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.
Source§

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.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more