Skip to main content

HeadlessPlatform

Struct HeadlessPlatform 

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

Deterministic offscreen platform backend available on all targets for CI and pixel-parity testing.

Implementations§

Source§

impl HeadlessPlatform

Configuration and event injection helpers for HeadlessPlatform.

Source

pub fn emulating( platform: PlatformKind, scale_factor: f32, safe_area: SafeAreaInsets, ) -> Self

Creates a headless platform emulating a specific target platform’s form factor and DPI.

§Arguments
  • PlatformKind - Target platform to emulate.
  • f32 - Simulated DPI scale factor.
  • SafeAreaInsets - Simulated safe-area insets.
§Returns
  • Self - Configured headless backend.
Source

pub fn with_refresh_rate_hz(self, hz: f32) -> Self

Overrides the simulated hardware refresh rate in Hertz for deterministic high-refresh testing.

§Arguments
  • Self - Headless platform builder.
  • f32 - Simulated display refresh rate in Hertz (24.0..=480.0).
§Returns
  • Self - Updated headless backend.
Source

pub fn push_event(&mut self, event: WindowEvent)

Enqueues a synthetic WindowEvent to be consumed on the next poll_events() call.

§Arguments
  • &Self - Mutable headless platform.
  • WindowEvent - Synthetic event to inject.
Source

pub fn push_system_event(&mut self, event: SystemEvent)

Enqueues a synthetic SystemEvent wrapped as PlatformEvent::System for deterministic testing.

§Arguments
  • &Self - Mutable headless platform.
  • SystemEvent - System event to inject.
Source

pub fn last_framebuffer(&self, id: WindowId) -> Option<&Framebuffer>

Returns a reference to the last presented Framebuffer for id.

§Arguments
  • &Self - Headless platform reference.
  • WindowId - Window identifier.
§Returns
  • Option<&Framebuffer> - Most recently presented pixel buffer.
Source§

impl HeadlessPlatform

Source

pub fn get_emulated_kind(&self) -> PlatformKind

Source

pub fn get_mut_emulated_kind(&mut self) -> &mut PlatformKind

Source

pub fn set_emulated_kind(&mut self, val: PlatformKind) -> &mut Self

Source

pub fn get_scale_factor(&self) -> f32

Source

pub fn get_mut_scale_factor(&mut self) -> &mut f32

Source

pub fn set_scale_factor(&mut self, val: f32) -> &mut Self

Source

pub fn get_safe_area(&self) -> SafeAreaInsets

Source

pub fn get_mut_safe_area(&mut self) -> &mut SafeAreaInsets

Source

pub fn set_safe_area(&mut self, val: SafeAreaInsets) -> &mut Self

Source

pub fn get_theme(&self) -> ThemeMode

Source

pub fn get_mut_theme(&mut self) -> &mut ThemeMode

Source

pub fn set_theme(&mut self, val: ThemeMode) -> &mut Self

Source

pub fn get_windows(&self) -> &HashMap<WindowId, HeadlessWindowRecord>

Source

pub fn get_mut_windows( &mut self, ) -> &mut HashMap<WindowId, HeadlessWindowRecord>

Source

pub fn set_windows( &mut self, val: HashMap<WindowId, HeadlessWindowRecord>, ) -> &mut Self

Source

pub fn get_pending_events(&self) -> &Vec<WindowEvent>

Source

pub fn get_mut_pending_events(&mut self) -> &mut Vec<WindowEvent>

Source

pub fn set_pending_events(&mut self, val: Vec<WindowEvent>) -> &mut Self

Source

pub fn get_mut_clipboard(&mut self) -> &mut Option<String>

Source

pub fn set_clipboard(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_pump_paused(&self) -> bool

Source

pub fn get_mut_pump_paused(&mut self) -> &mut bool

Source

pub fn set_pump_paused(&mut self, val: bool) -> &mut Self

Source

pub fn get_wait_calls(&self) -> u64

Source

pub fn get_mut_wait_calls(&mut self) -> &mut u64

Source

pub fn set_wait_calls(&mut self, val: u64) -> &mut Self

Trait Implementations§

Source§

impl Clone for HeadlessPlatform

Source§

fn clone(&self) -> Self

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 Debug for HeadlessPlatform

Source§

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

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

impl Default for HeadlessPlatform

Default HeadlessPlatform at 1.0x scale and Light theme.

Source§

fn default() -> Self

Creates a clean offscreen headless platform backend.

§Returns
  • Self - Default HeadlessPlatform.
Source§

impl PlatformBackend for HeadlessPlatform

PlatformBackend implementation for HeadlessPlatform.

Source§

fn kind(&self) -> PlatformKind

Returns the emulated PlatformKind.

§Arguments
  • &Self - Platform reference.
§Returns
  • PlatformKind - Emulated platform kind.
Source§

fn capabilities(&self) -> PlatformCapabilities

Returns normalized capabilities for the emulated platform.

§Arguments
  • &Self - Platform reference.
§Returns
  • PlatformCapabilities - Capability matrix.
Source§

fn create_window( &mut self, config: &WindowConfig, ) -> Result<WindowState, PlatformError>

Allocates an offscreen window record with simulated DPI and safe-area insets.

§Arguments
  • &Self - Mutable headless platform.
  • &WindowConfig - Window configuration.
§Returns
  • Result<WindowState, PlatformError> - Created window state.
Source§

fn window_state(&self, id: WindowId) -> Option<WindowState>

Queries current WindowState for id.

§Arguments
  • &Self - Platform reference.
  • WindowId - Window handle.
§Returns
  • Option<WindowState> - Window state if alive.
Source§

fn raw_window_handle(&self, _id: WindowId) -> RawWindowHandle

Returns RawWindowHandle::Headless.

§Arguments
  • &Self - Platform reference.
  • WindowId - Window handle.
§Returns
  • RawWindowHandle - Headless handle.
Source§

fn poll_events(&mut self) -> Vec<WindowEvent>

Drains injected synthetic events.

§Arguments
  • &Self - Mutable headless platform.
§Returns
  • Vec<WindowEvent> - Pending events.
Source§

fn wait_for_events(&mut self) -> Vec<WindowEvent>

Records a background wait invocation and drains any queued synthetic events immediately.

§Arguments
  • &Self - Mutable headless platform.
§Returns
  • Vec<WindowEvent> - Pending events.
Source§

fn set_frame_pump_paused(&mut self, paused: bool)

Updates headless frame pump pause state for deterministic background freeze testing.

§Arguments
  • &Self - Mutable headless platform.
  • bool - true when paused in background; false when active.
Source§

fn is_frame_pump_paused(&self) -> bool

Returns whether the headless frame pump is currently paused.

§Arguments
  • &Self - Platform reference.
§Returns
  • bool - true when paused in background.
Source§

fn present_framebuffer( &mut self, id: WindowId, framebuffer: &Framebuffer, ) -> Result<(), PlatformError>

Stores a copy of framebuffer inside the headless window record for pixel inspection.

§Arguments
  • &Self - Mutable headless platform.
  • WindowId - Target window handle.
  • &Framebuffer - Rendered RGBA8 framebuffer.
§Returns
  • Result<(), PlatformError> - Presentation status.
Source§

fn read_clipboard(&self) -> Option<String>

Reads the simulated clipboard string.

§Arguments
  • &Self - Platform reference.
§Returns
  • Option<String> - Stored clipboard contents.
Source§

fn write_clipboard(&mut self, text: &str) -> Result<(), PlatformError>

Writes text into the simulated clipboard.

§Arguments
  • &Self - Mutable platform.
  • &str - Clipboard text.
§Returns
  • Result<(), PlatformError> - Always succeeds.
Source§

fn system_theme(&self) -> ThemeMode

Returns the simulated OS theme mode.

§Arguments
  • &Self - Platform reference.
§Returns
  • ThemeMode - Simulated theme mode.
Source§

fn display_refresh_rate_hz(&self) -> f32

Returns the simulated display refresh rate in Hertz.

§Arguments
  • &Self - Platform reference.
§Returns
  • f32 - Simulated refresh rate in Hertz.
Source§

fn present_framebuffer_region( &mut self, id: WindowId, framebuffer: &Framebuffer, _damage: DamageRegion, ) -> Result<(), PlatformError>

Presents a damaged sub-region of a CPU-rendered RGBA8 Framebuffer when supported by the backend. Read more
Source§

impl WindowController for HeadlessPlatform

WindowController implementation for HeadlessPlatform.

Source§

fn apply_command(&mut self, command: WindowCommand) -> Result<(), PlatformError>

Applies a WindowCommand against the in-memory headless window record.

§Arguments
  • &Self - Mutable headless platform.
  • WindowCommand - Command to apply.
§Returns
  • Result<(), PlatformError> - Success or WindowNotFound.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.