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§
Sourcetype Error: Error
type Error: Error
The error build_presenter can fail with.
Required Methods§
Sourcefn scale(self, scale: u16) -> Self
fn scale(self, scale: u16) -> Self
Sets the integer pixel scale (each glyph pixel becomes scalexscale physical pixels).
Sourcefn font(self, fonts: impl Into<FontChain<'static>>) -> Self
fn font(self, fonts: impl Into<FontChain<'static>>) -> Self
Sets the fonts glyphs are resolved through.
Sourcefn tileset(self, opts: TilesetOptions) -> Self
fn tileset(self, opts: TilesetOptions) -> Self
Registers a PNG sprite tileset. Available only with the tilesets feature.
Sourcefn build_presenter(self) -> Result<Self::Presenter, Self::Error>
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".