Skip to main content

run_default

Function run_default 

Source
pub fn run_default<A>(
    app: A,
) -> Result<(), <Windowed<SoftwareBackendBuilder> as Launch>::Error>
where A: App<<Windowed<SoftwareBackendBuilder> as Launch>::Backend> + 'static,
Expand description

Picks a backend from this crate’s enabled Cargo features and drives app on it, using that backend’s own default configuration.

See the priority order above. Each backend is built with PresenterBuilder::new() for a windowed backend, paced by RunOptions::default(), or Crossterm::builder() for the terminal one.

This is the zero-config fast path, not a general-purpose driver: an app that needs a specific grid size, window title, tileset, or pacing has outgrown “default” and should call that backend’s own Launch::launch directly instead, e.g. Windowed::new(builder, "My Game").launch(app, RunOptions::animated(60)) or Crossterm::builder().launch(app, options).

Absent entirely (not a compile error) when none of crossterm, software, gl, or wgpu is enabled: there is no backend left to pick.

§Errors

Returns the picked backend’s own Launch::Error if it fails to launch; see that backend’s Launch impl for the exact conditions (a real terminal that can’t enter raw mode, a presenter that fails to build, or a window/event loop that fails to start or run).