pub struct Application { /* private fields */ }Expand description
Create a new winit application.
§Example
use winit::{event::WindowEvent, window::WindowAttributes};
use winit_app::Application;
fn launch_app() -> Result<(), Box<dyn std::error::Error>> {
let winit_app = Application::new();
winit_app.run(
WindowAttributes::default().with_title("Sample"),
|app_window_event| match app_window_event {
_ => {
// TODO: Handle those events
}
},
)?;
Ok(())
}Implementations§
Source§impl<'a> Application
impl<'a> Application
pub fn new() -> Self
Sourcepub fn with_control_flow(&mut self, control_flow: ControlFlow) -> &Self
pub fn with_control_flow(&mut self, control_flow: ControlFlow) -> &Self
Sets the control flow of this application
ControlFlow::Poll continuously runs the event loop, even if the OS hasn’t
dispatched any events. This is ideal for games and similar applications.
ControlFlow::Wait pauses the event loop if no events are available to process.
This is ideal for non-game applications that only update in response to user
input, and uses significantly less power/CPU time than ControlFlow::Poll.
pub fn run<F>(
&'a self,
window_attributes: WindowAttributes,
listener: F,
) -> WinitAppResult<()>where
F: FnMut(AppWindowEvent<'_>) + 'static,
Trait Implementations§
Source§impl Default for Application
impl Default for Application
Source§fn default() -> Application
fn default() -> Application
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Application
impl RefUnwindSafe for Application
impl Send for Application
impl Sync for Application
impl Unpin for Application
impl UnwindSafe for Application
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
Mutably borrows from an owned value. Read more
§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>
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>
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)
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)
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.