App

Struct App 

Source
pub struct App { /* private fields */ }
Expand description

Main application struct that manages the game loop and plugin lifecycle

The App coordinates:

  • Plugin registration and initialization
  • System scheduling (startup and per-frame)
  • Main loop execution
  • Resource cleanup on shutdown

§Example

use kon::prelude::*;

fn main() {
    Kon::new()
        .add_plugin(DefaultPlugins)
        .add_startup_system(setup)
        .add_system(update)
        .run();

Implementations§

Source§

impl App

Source

pub fn new() -> App

Creates a new App instance

Initializes logging and installs custom panic handler

Source

pub fn add_plugin<P>(&mut self, plugin: P) -> &mut App
where P: Plugin,

Adds a plugin to the application

Plugins extend engine functionality. Common examples:

  • EcsPlugin - Registers the World
  • WindowPlugin - Creates the game window
  • DefaultPlugins - Bundle of core plugins
§Returns

Self reference for method chaining

Source

pub fn add_startup_system<F>(&mut self, system: F) -> &mut App
where F: FnMut(&mut Context) + 'static,

Adds a startup system that runs once at application start

§Returns

Self reference for method chaining

Source

pub fn add_system<F>(&mut self, system: F) -> &mut App
where F: FnMut(&mut Context) + 'static,

Adds a system that runs every frame

§Returns

Self reference for method chaining

Source

pub fn register<R>(&mut self, resource: R) -> &mut App
where R: Any + Send + Sync + 'static,

Registers a global resource accessible from all systems

Resources are stored in Context and accessible via ctx.global::<T>().

§Returns

Self reference for method chaining

Source

pub fn context(&self) -> &Context

Returns an immutable reference to the engine context

Source

pub fn context_mut(&mut self) -> &mut Context

Returns a mutable reference to the engine context

Source

pub fn run(&mut self)

Runs the application main loop

§Lifecycle
  1. Initialize all plugins (call ready())
  2. Execute startup systems once
  3. Run main loop until ctx.quit() is called:
    • Update frame timing
    • Execute all systems in order
    • Clear events (prevents stale data next frame)
  4. Cleanup plugins on exit

Trait Implementations§

Source§

impl Default for App

Source§

fn default() -> App

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

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.