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.
impl<A: 'static, D> WinitHost<A, D>
Host construction, attachment, state access, and diagnostic drains.
Sourcepub fn new(ui: UiApp<A>, driver: D) -> Self
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());Sourcepub fn test_service(self, service: impl FnMut(&mut UiApp<A>) + 'static) -> Self
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;Sourcepub fn runtime_inbox(self, inbox: RuntimeInbox<A>) -> Self
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;Sourcepub fn ui(&self) -> &UiApp<A>
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();Sourcepub fn ui_mut(&mut self) -> &mut UiApp<A>
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();Sourcepub fn driver(&self) -> &D
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();Sourcepub fn driver_mut(&mut self) -> &mut D
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();Sourcepub fn take_error(&mut self) -> Option<UiAppError>
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());Sourcepub fn take_inbox_wake_error(&mut self) -> Option<UiWakeError>
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());Sourcepub fn take_capture_wake_error(&mut self) -> Option<UiWakeError>
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());Sourcepub fn take_devtools_wake_error(&mut self) -> Option<UiWakeError>
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.
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)
fn resumed(&mut self, event_loop: &ActiveEventLoop)
Recreates native presentations before servicing application work.
Source§fn suspended(&mut self, event_loop: &ActiveEventLoop)
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,
)
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: ())
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)
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)
fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause)
§fn device_event(
&mut self,
event_loop: &ActiveEventLoop,
device_id: DeviceId,
event: DeviceEvent,
)
fn device_event( &mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent, )
§fn exiting(&mut self, event_loop: &ActiveEventLoop)
fn exiting(&mut self, event_loop: &ActiveEventLoop)
§fn memory_warning(&mut self, event_loop: &ActiveEventLoop)
fn memory_warning(&mut self, event_loop: &ActiveEventLoop)
Auto Trait Implementations§
impl<A, D> Freeze for WinitHost<A, D>
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>
impl<A, D> !UnwindSafe for WinitHost<A, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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