Skip to main content

Engine

Struct Engine 

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

Mirrors the role of euv::App: every public engine operation begins with an Engine::xxx call, and Engine itself holds no state.

Source

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

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 be None and is_running will be false. Initialization errors are not logged inside the engine; callers should call init_webgpu directly if they need access to the typed WebGpuInitError.
Source

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

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, or None if the canvas element was not found.
Source

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.

Trait Implementations§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Engine

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Engine

Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Engine

Source§

fn default() -> Engine

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

impl Eq for Engine

Source§

impl Hash for Engine

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Engine

Source§

fn cmp(&self, other: &Engine) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Engine

Source§

fn eq(&self, other: &Engine) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Engine

Source§

fn partial_cmp(&self, other: &Engine) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Engine

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more