Skip to main content

HeadlessPlatform

Struct HeadlessPlatform 

Source
pub struct HeadlessPlatform { /* private fields */ }
Expand description

A first-class, windowless Platform backend: it drives the exact same EventHandler seam as the winit backend (on_resume → scripted on_events → on_redraws → on_suspend) against a HeadlessWindow, with no event loop, GPU swapchain, or display server. Because the handler builds an offscreen renderer for a headless window, this routes a real app end-to-end (event → reactive → layout → render → pixels) and is both the reference Platform impl and a deterministic integration-test harness.

Construct it with the surface size, optionally script input events and a frame count, and optionally capture the final frame’s pixels; then drive it via [crate::run-style entry points] — e.g. telar::run_with_platform(HeadlessPlatform::new(w, h).capture_into(sink), …).

Implementations§

Source§

impl HeadlessPlatform

Source

pub fn new(width: u32, height: u32) -> Self

A width×height offscreen surface at scale 1.0, no scripted events, one render frame.

Source

pub fn with_scale_factor(self, scale_factor: f64) -> Self

Report a HiDPI scale factor to the app (drives logical-vs-physical sizing).

Source

pub fn with_prefers_dark(self, prefers_dark: Option<bool>) -> Self

Report an OS light/dark preference (Some(true) = dark) before the tree mounts.

Source

pub fn with_events(self, events: Vec<Event>) -> Self

Scripted input events delivered (in order) after on_resume, each as its own loop iteration.

Source

pub fn with_frames(self, frames: u32) -> Self

How many render frames to drive after the scripted events. Defaults to 1. Use more to let animations or multi-pass reactive settling converge before the final pixels are captured.

Source

pub fn capture_into(self, sink: FrameSink) -> Self

Capture the final frame’s premultiplied RGBA8 pixels into sink, readable after run returns.

Source

pub fn capture_surfaces_into(self, sink: SurfaceFrameSink) -> Self

Capture each surface’s final frame into sink, keyed by SurfaceId, readable after MultiSurfacePlatform::run_surfaces returns. Only consulted by the multi-surface path.

Trait Implementations§

Source§

impl MultiSurfacePlatform for HeadlessPlatform

Source§

type Window = HeadlessWindow

Source§

fn run_surfaces<H, F>( self, surfaces: Vec<(SurfaceId, WindowConfig)>, factory: F, ) -> Result<(), PlatformError>
where H: EventHandler<HeadlessWindow> + 'static, F: Fn(SurfaceId) -> H + 'static,

Runs every surface in surfaces (each an (id, config) pair), building its handler via factory(id). Blocks until all surfaces have closed.
Source§

impl Platform for HeadlessPlatform

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