nexus_rt/plugin.rs
1//! Plugin trait for composable resource registration.
2
3use crate::world::WorldBuilder;
4
5/// Composable unit of resource registration.
6///
7/// Plugins register resources into a [`WorldBuilder`]. The runtime is
8/// assembled by installing plugins via [`WorldBuilder::install_plugin`].
9///
10/// # Examples
11///
12/// ```ignore
13/// struct TradingPlugin;
14///
15/// impl Plugin for TradingPlugin {
16/// fn build(self, world: &mut WorldBuilder) {
17/// world.register(PriceCache::new());
18/// world.register(TradeState::default());
19/// }
20/// }
21///
22/// let mut wb = WorldBuilder::new();
23/// wb.install_plugin(TradingPlugin);
24/// ```
25pub trait Plugin {
26 /// Register resources into the world.
27 fn build(self, world: &mut WorldBuilder);
28}