Skip to main content

PresenterBuilder

Trait PresenterBuilder 

Source
pub trait PresenterBuilder: Sized {
    type Presenter: Presenter + 'static;
    type Error: Error;

    // Required methods
    fn new() -> Self;
    fn grid_size(self, cols: u16, rows: u16) -> Self;
    fn scale(self, scale: u16) -> Self;
    fn font(self, fonts: impl Into<FontChain<'static>>) -> Self;
    fn tileset(self, opts: TilesetOptions) -> Self;
    fn build_presenter(self) -> Result<Self::Presenter, Self::Error>;
}
Expand description

The builder shape retroglyph-software, retroglyph-gl, and retroglyph-wgpu all implement.

SoftwareBackendBuilder, GlBackendBuilder, and WgpuBackendBuilder are otherwise unrelated types: each crate defines its own builder because each backend owns its own renderer and error type, but the configuration surface (grid size, scale, fonts, tilesets) is identical across all three. This trait names that shared surface so a caller (a demo gallery, a test harness) can be generic over “a windowed backend’s builder” instead of writing one near-identical function per backend crate (retroglyph#1192).

A backend crate implements this by forwarding to its existing inherent methods; see SoftwareBackendBuilder, GlBackendBuilder, and WgpuBackendBuilder for the impls.

Required Associated Types§

Source

type Presenter: Presenter + 'static

The renderer this builder produces.

Source

type Error: Error

The error build_presenter can fail with.

Required Methods§

Source

fn new() -> Self

Creates a builder with the backend’s default configuration.

Source

fn grid_size(self, cols: u16, rows: u16) -> Self

Sets the grid dimensions in cells.

Source

fn scale(self, scale: u16) -> Self

Sets the integer pixel scale (each glyph pixel becomes scalexscale physical pixels).

Source

fn font(self, fonts: impl Into<FontChain<'static>>) -> Self

Sets the fonts glyphs are resolved through.

Source

fn tileset(self, opts: TilesetOptions) -> Self

Registers a PNG sprite tileset. Available only with the tilesets feature.

Source

fn build_presenter(self) -> Result<Self::Presenter, Self::Error>

Builds the configured Presenter.

§Errors

Returns Self::Error if the configuration is invalid (see the backend crate’s own error type for the exact conditions: missing font, mismatched glyph sizes, zero scale/grid, an oversized surface, or a tileset that failed to load).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§