bevy/crates/bevy_app/src/plugin.rs

21 lines
777 B
Rust
Raw Normal View History

use crate::App;
2020-01-21 04:10:40 +00:00
use std::any::Any;
/// A collection of Bevy App logic and configuration
///
/// Plugins configure an [`App`](crate::App). When an [`App`](crate::App) registers
/// a plugin, the plugin's [`Plugin::build`] function is run.
2020-08-08 03:22:17 +00:00
pub trait Plugin: Any + Send + Sync {
/// Configures the [`App`] to which this plugin is added.
fn build(&self, app: &mut App);
/// Configures a name for the [`Plugin`]. Primarily for debugging.
2020-04-05 21:12:14 +00:00
fn name(&self) -> &str {
std::any::type_name::<Self>()
2020-04-05 21:12:14 +00:00
}
2020-01-21 04:10:40 +00:00
}
/// Type representing an unsafe function that returns a mutable pointer to a [`Plugin`].
/// Used for dynamically loading plugins. See
/// `bevy_dynamic_plugin/src/loader.rs#dynamically_load_plugin`
2020-08-08 03:22:17 +00:00
pub type CreatePlugin = unsafe fn() -> *mut dyn Plugin;