Struct WinitHost

Source
pub struct WinitHost<A, D> { /* private fields */ }
Expand description

The sole ApplicationHandler used by the high-level Ailloli UI application path.

A host owns one retained UiApp, one provider-neutral driver, and at most one bounded runtime inbox. All native, capture, inbox, and devtools wake sources share the event-loop proxy installed by run_winit_host.

§Examples

use ailloli_ui_winit::{NoopHostDriver, UiApp, WinitHost};
let host = WinitHost::new(UiApp::<()>::new(), NoopHostDriver);
assert!(host.ui().window_snapshots().is_empty());

Implementations§

Source§

impl<A: 'static, D> WinitHost<A, D>

Host construction, attachment, state access, and diagnostic drains.

Source

pub fn new(ui: UiApp<A>, driver: D) -> Self

Wraps a retained UI application and a provider-neutral driver.

No inbox, wake proxy, test service, or stored wake error is installed.

§Examples
use ailloli_ui_winit::{NoopHostDriver, UiApp, WinitHost};
let mut host: WinitHost<(), NoopHostDriver> = WinitHost::new(UiApp::new(), NoopHostDriver);
assert!(host.take_error().is_none());
Source

pub fn test_service(self, service: impl FnMut(&mut UiApp<A>) + 'static) -> Self

Installs an event-loop-thread service used only by native test drivers.

The callback runs after the UI host has processed each native callback, so deterministic event envelopes can be injected into live windows before their capture frame. This hook is intentionally unavailable without test_support and is not re-exported by the facade. Repeated calls replace the previous callback.

§Examples
use ailloli_ui_winit::{NoopHostDriver, UiApp, WinitHost};
let host = WinitHost::new(UiApp::<()>::new(), NoopHostDriver)
    .test_service(|ui| ui.request_redraw_all());
let _ = host;
Source

pub fn runtime_inbox(self, inbox: RuntimeInbox<A>) -> Self

Attaches the single bounded mailbox drained by this host.

In debug builds, attaching a second inbox to the same builder value panics. Each host callback drains at most the inbox’s configured service budget (the runtime default is 256 messages).

§Examples
use std::num::NonZeroUsize;
use ailloli_ui_runtime::app::RuntimeInbox;
use ailloli_ui_winit::{NoopHostDriver, UiApp, WinitHost};
let (_sender, inbox) = RuntimeInbox::<()>::channel(NonZeroUsize::new(4).unwrap());
let host = WinitHost::new(UiApp::new(), NoopHostDriver).runtime_inbox(inbox);
let _ = host;
Source

pub fn ui(&self) -> &UiApp<A>

Retained UI application.

§Examples
let host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
let _: &ailloli_ui_winit::UiApp<()> = host.ui();
Source

pub fn ui_mut(&mut self) -> &mut UiApp<A>

Mutable retained UI application.

§Examples
let mut host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
host.ui_mut().request_redraw_all();
Source

pub fn driver(&self) -> &D

Provider-neutral driver.

§Examples
let host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
let _: &ailloli_ui_winit::NoopHostDriver = host.driver();
Source

pub fn driver_mut(&mut self) -> &mut D

Mutable provider-neutral driver.

§Examples
let mut host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
let _: &mut ailloli_ui_winit::NoopHostDriver = host.driver_mut();
Source

pub fn take_error(&mut self) -> Option<UiAppError>

Takes the first UI host error, if any.

The slot is destructive: a second call returns None unless another error has occurred.

§Examples
let mut host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
assert!(host.take_error().is_none());
Source

pub fn take_inbox_wake_error(&mut self) -> Option<UiWakeError>

Takes the first non-fatal mailbox wake error observed by the host.

§Examples
let mut host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
assert!(host.take_inbox_wake_error().is_none());
Source

pub fn take_capture_wake_error(&mut self) -> Option<UiWakeError>

Takes the first non-fatal capture wake error observed by the host.

A host-latched installation error has priority over an error still held by the capture handle. The selected error is consumed.

§Examples
let mut host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
assert!(host.take_capture_wake_error().is_none());
Source

pub fn take_devtools_wake_error(&mut self) -> Option<UiWakeError>

Takes the first non-fatal remote-devtools wake error observed by the host.

A host-latched error has priority over the remote subsystem’s slot. The selected error is consumed.

§Examples
let mut host = ailloli_ui_winit::WinitHost::new(
    ailloli_ui_winit::UiApp::<()>::new(), ailloli_ui_winit::NoopHostDriver);
assert!(host.take_devtools_wake_error().is_none());

Trait Implementations§

Source§

impl<A: 'static, D: HostDriver<A>> ApplicationHandler for WinitHost<A, D>

Routes every winit callback through the UI host, then the ordered service pipeline.

Source§

fn resumed(&mut self, event_loop: &ActiveEventLoop)

Recreates native presentations before servicing application work.

Source§

fn suspended(&mut self, event_loop: &ActiveEventLoop)

Detaches native presentations before servicing application work.

Source§

fn window_event( &mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent, )

Routes one native window event before servicing application work.

Source§

fn user_event(&mut self, event_loop: &ActiveEventLoop, event: ())

Treats unit user events as wake-only notifications, then services work.

Source§

fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)

Services work and configures the next event-loop sleep deadline.

§

fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause)

Emitted when new events arrive from the OS to be processed. Read more
§

fn device_event( &mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent, )

Emitted when the OS sends an event to a device.
§

fn exiting(&mut self, event_loop: &ActiveEventLoop)

Emitted when the event loop is being shut down. Read more
§

fn memory_warning(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has received a memory warning. Read more

Auto Trait Implementations§

§

impl<A, D> Freeze for WinitHost<A, D>
where D: Freeze, A: Freeze,

§

impl<A, D> !RefUnwindSafe for WinitHost<A, D>

§

impl<A, D> !Send for WinitHost<A, D>

§

impl<A, D> !Sync for WinitHost<A, D>

§

impl<A, D> Unpin for WinitHost<A, D>
where D: Unpin, A: Unpin,

§

impl<A, D> !UnwindSafe for WinitHost<A, D>

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,