pub struct App {
pub world: World,
/* private fields */
}Expand description
The App struct holds all the apps data and defines the necessary functions and methods to operate on it.
Fields§
§world: WorldImplementations§
Source§impl App
impl App
Sourcepub fn add_module(&mut self, module: impl Module + 'static)
pub fn add_module(&mut self, module: impl Module + 'static)
Add a Module to the App. If it already exists, nothing happens.
§Example
use magma_app::{module::Module, App};
let mut app = App::new();
app.add_module(ExampleModule);
struct ExampleModule;
impl Module for ExampleModule {
fn setup(self, app: &mut App) {
// Setup the module
// E.g. register components to the World or add resources
}
}Sourcepub fn register_schedule<S: AppSchedule + 'static>(&mut self)
pub fn register_schedule<S: AppSchedule + 'static>(&mut self)
Register an AppSchedule.
Sourcepub fn run_schedule<S: AppSchedule + 'static>(
&self,
) -> Result<(), ScheduleError>
pub fn run_schedule<S: AppSchedule + 'static>( &self, ) -> Result<(), ScheduleError>
Run an AppSchedule.
Sourcepub fn add_systems<S: AppSchedule + 'static>(
&mut self,
systems: &'static [(fn(&World), &'static str, &'static [&'static str])],
) -> Result<(), ScheduleError>
pub fn add_systems<S: AppSchedule + 'static>( &mut self, systems: &'static [(fn(&World), &'static str, &'static [&'static str])], ) -> Result<(), ScheduleError>
Add systems to the App’s World. Systems must take an immutable reference to World.
§Errors
Returns an error, when the schedule isn’t registered.
§Example
use magma_app::{App, World};
use magma_app::schedule::Startup;
let mut app = App::new();
app.add_systems::<Startup>(&[(example_system, "example_system", &[])]).unwrap();
fn example_system(_world: &World) {
// E.g. change something in the World
}pub fn register_event<E: Any + Send + Sync + Clone>(&mut self)
pub fn add_event_systems<E: Any + Send + Sync + Clone>( &mut self, systems: &'static [(fn(&World), &'static str, &'static [&'static str])], ) -> Result<(), EventError>
Sourcepub fn set_runner(&mut self, runner: fn(App))
pub fn set_runner(&mut self, runner: fn(App))
Set the runner of the App
Sourcepub fn process_events(&self)
pub fn process_events(&self)
Process pending events.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for App
impl !RefUnwindSafe for App
impl Send for App
impl Sync for App
impl Unpin for App
impl !UnwindSafe for App
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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