pub struct Engine;Expand description
A zero-sized namespace struct providing static engine entry points.
This struct follows the same pattern as euv::App, serving as the
single root namespace for all top-level engine operations: creating
engine handles, initializing rendering backends, and starting the
fixed-timestep game loop.
All engine usage flows through Engine::xxx static calls, mirroring
how euv::App::use_signal / euv::App::mount are the public entry
points of the core framework.
Implementations§
Source§impl Engine
Implements the top-level static engine entry points on the Engine namespace.
impl Engine
Implements the top-level static engine entry points on the Engine namespace.
Mirrors the role of euv::App: every public engine operation begins
with an Engine::xxx call, and Engine itself holds no state.
Sourcepub fn new_handle(config: EngineConfig) -> EngineHandle
pub fn new_handle(config: EngineConfig) -> EngineHandle
Creates a new engine handle bound to the given configuration.
The handle is uninitialized; call init_canvas / init_webgpu and
start on the returned handle to begin the game loop, or use
Engine::run for the one-line equivalent.
§Arguments
EngineConfig- The engine configuration.
§Returns
EngineHandle- The new uninitialized engine handle.
Sourcepub async fn run(config: EngineConfig, handler: TickHandlerRc) -> EngineHandle
pub async fn run(config: EngineConfig, handler: TickHandlerRc) -> EngineHandle
Runs the engine through its complete lifecycle in a single async call.
Equivalent to calling Engine::new_handle(config) followed by
init_canvas / init_webgpu (matching the chosen backend) and
start(handler). The returned handle can still be used to stop
the loop later via handle.stop().
§Arguments
EngineConfig- The engine configuration.TickHandlerRc- The tick handler receiving update and render callbacks.
§Returns
EngineHandle- A handle to the running engine. If renderer initialization failed the handle’s renderer field will beNoneandis_runningwill befalse. Initialization errors are not logged inside the engine; callers should callinit_webgpudirectly if they need access to the typedWebGpuInitError.
Sourcepub fn default_config() -> EngineConfig
pub fn default_config() -> EngineConfig
Returns the default engine configuration.
Uses RenderConfig::default() (Canvas 2D backend) and the default
scheduler configuration (60 Hz fixed timestep).
§Returns
EngineConfig- The default engine configuration.
Sourcepub fn canvas_renderer(config: &RenderConfig) -> Option<CanvasRenderer>
pub fn canvas_renderer(config: &RenderConfig) -> Option<CanvasRenderer>
Creates a Canvas 2D renderer directly from a render configuration.
Use this when you want a CanvasRenderer without going through
the full EngineHandle lifecycle (for example, in a custom render
loop that does not use the fixed-timestep scheduler).
§Arguments
&RenderConfig- The rendering configuration.
§Returns
Option<CanvasRenderer>- The renderer, orNoneif the canvas element was not found.
Sourcepub async fn webgpu_renderer(
config: &RenderConfig,
) -> Result<WebGpuRenderer, WebGpuInitError>
pub async fn webgpu_renderer( config: &RenderConfig, ) -> Result<WebGpuRenderer, WebGpuInitError>
Creates a WebGPU renderer directly from a render configuration.
Async because GPU adapter and device acquisition returns JavaScript
Promises that must be awaited. Mirrors Engine::canvas_renderer for
callers that want the renderer without the full engine handle.
Failures are surfaced as WebGpuInitError so the caller can decide
how to react (typically by logging via Console::error or by
falling back to the Canvas 2D backend).
§Arguments
&RenderConfig- The rendering configuration.
§Returns
Result<WebGpuRenderer, WebGpuInitError>- The initialized renderer, or a typed error describing the specific failure.