Trait HostDriver

Source
pub trait HostDriver<A>: 'static {
    // Required method
    fn service(
        &mut self,
        runtime: &RuntimeHandle<A>,
        now: Instant,
    ) -> HostOutcome;
}
Expand description

Provider-neutral application logic serviced after native host callbacks.

Implementations run on the event-loop thread after UI sources, runtime inbox messages, capture requests, and optional devtools commands are serviced.

§Examples

use std::time::Instant;
use ailloli_ui_runtime::app::RuntimeHandle;
use ailloli_ui_winit::{HostDriver, HostOutcome};
struct Driver;
impl HostDriver<()> for Driver {
    fn service(&mut self, _runtime: &RuntimeHandle<()>, _now: Instant) -> HostOutcome {
        HostOutcome::default()
    }
}

Required Methods§

Source

fn service(&mut self, runtime: &RuntimeHandle<A>, now: Instant) -> HostOutcome

Drains application work and returns host-level effects.

now is sampled immediately before the call. A next_wake deadline is passed to the UI host, while redraw and exit effects are applied immediately.

§Examples
use std::time::Instant;
use ailloli_ui_runtime::app::RuntimeHandle;
use ailloli_ui_winit::{HostDriver, HostOutcome};
struct ExitDriver;
impl HostDriver<()> for ExitDriver {
    fn service(&mut self, _: &RuntimeHandle<()>, _: Instant) -> HostOutcome {
        HostOutcome::exit()
    }
}

Implementors§

Source§

impl<A> HostDriver<A> for NoopHostDriver

Always returns the idle HostOutcome.