pub trait Component<R, E>{
// 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§
Sourcefn on_attach(&mut self, render_context: &mut RenderContext) -> Result<R, E>
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.
Sourcefn on_detach(&mut self, render_context: &mut RenderContext) -> Result<R, E>
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.
Sourcefn on_event(&mut self, event: Events) -> Result<R, E>
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.
Sourcefn on_update(&mut self, last_frame: &Duration) -> Result<R, E>
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.
Sourcefn on_render(
&mut self,
render_context: &mut RenderContext,
) -> Vec<RenderCommand>
fn on_render( &mut self, render_context: &mut RenderContext, ) -> Vec<RenderCommand>
Render commands returned from this function will be executed by the renderer immediately.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".