Skip to main content

bevy_extract/
lib.rs

1#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
2#![cfg_attr(
3    any(docsrs, docsrs_dep),
4    expect(
5        internal_features,
6        reason = "rustdoc_internals is needed for fake_variadic"
7    )
8)]
9#![cfg_attr(any(docsrs, docsrs_dep), feature(doc_cfg, rustdoc_internals))]
10#![doc(
11    html_logo_url = "https://bevy.org/assets/icon.png",
12    html_favicon_url = "https://bevy.org/assets/icon.png"
13)]
14#![expect(unsafe_code, reason = "Unsafe code is used to improve performance.")]
15
16//! This crate provides a way to extract component information from
17//! an app’s main world into a sub world.
18//!
19//! The easiest way to set up extract is to add the [`ExtractPlugin`] for your [`AppLabel`](`bevy_app::AppLabel`).
20//!
21//! Then derive `ExtractComponent` or `ExtractResource` - ensure that you specify the `extract_app` attribute.
22//!
23//! ```ignore
24//! #[derive(Component, Clone, Debug, ExtractComponent)]
25//! #[extract_app(SomeApp)]
26//! struct SomeComponent;
27//! ```
28//!
29//! This adds `SyncComponent` to first sync the entities from the main world to the sub world.
30//! And then sync the component data from the main entity to the sub entity.
31//!
32//! More complex use cases may want to manually implement the `ExtractComponent` or `ExtractResource` traits directly.
33//!
34//! For higher performance needs use the [`ExtractInstance`](`crate::extract_instances::ExtractInstance`) trait.
35//!
36//! The sub app can access the main world in the [`ExtractSchedule`](`crate::ExtractSchedule`).
37//! Adding a system with a query wrapped in [`Extract`](`crate::Extract`) and it will run against the main app world.
38//!
39//! [`SyncComponent`]: crate::sync_component::SyncComponent
40//! [`ExtractComponent`]: crate::extract_component::ExtractComponent
41//! [`ExtractResource`]: crate::extract_resource::ExtractResource
42
43extern crate alloc;
44
45pub mod extract_component;
46pub mod extract_instances;
47pub mod extract_param;
48pub mod extract_plugin;
49pub mod extract_resource;
50pub mod sync_component;
51pub mod sync_world;
52
53pub use extract_param::Extract;
54pub use extract_plugin::*;
55pub use extract_plugin::{ExtractSchedule, MainWorld};
56pub use sync_world::*;
57
58// Required to make proc macros work in bevy itself.
59extern crate self as bevy_extract;