Trait Component

Source
pub trait Component<R, E>
where R: Sized + Debug, E: Sized + Debug,
{ // Required methods fn on_attach(&mut self, render_context: &mut RenderContext) -> Result<R, E>; fn on_detach(&mut self, render_context: &mut RenderContext) -> Result<R, E>; fn on_event(&mut self, event: Events) -> Result<R, E>; fn on_update(&mut self, last_frame: &Duration) -> Result<R, E>; fn on_render( &mut self, render_context: &mut RenderContext, ) -> Vec<RenderCommand>; }
Expand description

The Component Interface for allowing Component based data structures like the ComponentStack to store components with various purposes and implementations to work together.

Required Methods§

Source

fn on_attach(&mut self, render_context: &mut RenderContext) -> Result<R, E>

The attach function is called when the component is added to the component data storage a runtime is using.

Source

fn on_detach(&mut self, render_context: &mut RenderContext) -> Result<R, E>

The detach function is called when the component is removed from the component data storage a runtime is using.

Source

fn on_event(&mut self, event: Events) -> Result<R, E>

The event function is called every time an event is received from the windowing system/event loop.

Source

fn on_update(&mut self, last_frame: &Duration) -> Result<R, E>

The update function is called every frame and is used to update the state of the component.

Source

fn on_render( &mut self, render_context: &mut RenderContext, ) -> Vec<RenderCommand>

Render commands returned from this function will be executed by the renderer immediately.

Implementors§