Skip to main content

HeadlessHost

Struct HeadlessHost 

Source
pub struct HeadlessHost<S: Spec, A: App<Spec = S>> {
    pub caps: HostCaps,
    pub dpr: f64,
    pub ctx: RecordingRenderContext,
    /* private fields */
}
Expand description

A runtime driven by hand: no event loop, no wall clock, no GPU.

Fields§

§caps: HostCaps

Capabilities reported in every Created echo.

§dpr: f64

Device pixel ratio reported for auto-answered spawned windows.

§ctx: RecordingRenderContext

The paint recorder of the last advance (draw ops are inspectable through it; it is reused, so it accumulates — call RecordingRenderContext accessors per test section).

Implementations§

Source§

impl<S: Spec, A: App<Spec = S>> HeadlessHost<S, A>

Source

pub fn new(app: A, cfg: RuntimeConfig) -> (Self, Handle<S>)

A host and the app’s handle, with a no-op waker (design §9.1).

Source

pub fn open_window(&mut self, size: SizePx, dpr: f64) -> WindowId

Open a window and run the ticks that settle its creation (the Spawn command is auto-answered with a Created echo carrying size and dpr). Returns the engine-assigned id.

Source

pub fn input(&mut self, win: WindowId, event: InputEvent)

Queue one input event for the next tick (hop 1 of §4.4).

Source

pub fn advance(&mut self, dt: f64) -> &TickOutput

Move the host clock by dt seconds, run one tick (plus one settling tick when the tick’s host-bound commands needed an echo answer), and paint every due frame request. The output of the whole advance is kept for HeadlessHost::window_commands.

Source

pub fn snapshot(&self) -> Arc<VisualSnapshot<S>> ⓘ

The last published snapshot.

Source

pub fn window_commands(&self) -> &[(WindowId, WindowCommand)]

The host-bound window commands of the last advance.

Source

pub fn command_log(&self) -> &[(WindowId, WindowCommand)]

Every host-bound window command since construction, in order (the executor’s own log — assertions over a whole script read this, not the last tick’s slice).

Source

pub fn runtime(&self) -> &Runtime<S, A>

The runtime (tests drive app-level tools through it).

Source

pub fn runtime_mut(&mut self) -> &mut Runtime<S, A>

The runtime, mutably.

Auto Trait Implementations§

§

impl<S, A> !RefUnwindSafe for HeadlessHost<S, A>

§

impl<S, A> !Sync for HeadlessHost<S, A>

§

impl<S, A> !UnwindSafe for HeadlessHost<S, A>

§

impl<S, A> Freeze for HeadlessHost<S, A>
where Runtime<S, A>: Freeze, Handle<S>: Freeze,

§

impl<S, A> Send for HeadlessHost<S, A>
where Runtime<S, A>: Send, Handle<S>: Send,

§

impl<S, A> Unpin for HeadlessHost<S, A>
where Runtime<S, A>: Unpin, Handle<S>: Unpin,

§

impl<S, A> UnsafeUnpin for HeadlessHost<S, A>

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

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.