struct App<E: Example> {
title: &'static str,
proxy: EventLoopProxy<AppAction>,
window: Option<Arc<Window>>,
frame_counter: FrameCounter,
occluded: bool,
state: AppState<E>,
}Expand description
The main application struct, implementing winit’s [ApplicationHandler].
Winit 0.30 requires that windows are not created until the resumed() callback,
and that all wgpu resources (instance, adapter, device) are initialized after the
window exists. On native, this init happens synchronously via pollster::block_on.
On wasm, it happens asynchronously via wasm_bindgen_futures::spawn_local, with
the results delivered back through an [EventLoopProxy] user event.
Fields§
§title: &'static str§proxy: EventLoopProxy<AppAction>§window: Option<Arc<Window>>§frame_counter: FrameCounter§occluded: bool§state: AppState<E>Implementations§
Trait Implementations§
Source§impl<E: Example> ApplicationHandler<AppAction> for App<E>
impl<E: Example> ApplicationHandler<AppAction> for App<E>
Source§fn resumed(&mut self, event_loop: &ActiveEventLoop)
fn resumed(&mut self, event_loop: &ActiveEventLoop)
Called when the application is (re)started. On the first call, the window and wgpu resources are created. On Android, this may be called again after each suspend — in that case we only need to re-create the surface.
Source§fn user_event(&mut self, _event_loop: &ActiveEventLoop, event: AppAction)
fn user_event(&mut self, _event_loop: &ActiveEventLoop, event: AppAction)
Receives the result of the async wgpu initialization. Creates the Example and
transitions to the running state.
Source§fn suspended(&mut self, _event_loop: &ActiveEventLoop)
fn suspended(&mut self, _event_loop: &ActiveEventLoop)
Source§fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
_window_id: WindowId,
event: WindowEvent,
)
fn window_event( &mut self, event_loop: &ActiveEventLoop, _window_id: WindowId, event: WindowEvent, )
§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 about_to_wait(&mut self, event_loop: &ActiveEventLoop)
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
§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<E> !Freeze for App<E>
impl<E> !RefUnwindSafe for App<E>
impl<E> Send for App<E>where
E: Send,
impl<E> Sync for App<E>where
E: Sync,
impl<E> Unpin for App<E>where
E: Unpin,
impl<E> !UnwindSafe for App<E>
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> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§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