pub struct EventLoop { /* private fields */ }
Expand description

Provides a way to retrieve events from the system and from the windows that were registered to the events loop.

The EventLoop is a “context” for the GUI system. More specifically, it represents a connection to the underlying GUI system. The EventLoop is the main object that you will use to drive the program. Most async functions in async-winit rely on the EventLoop to be currently running.

The EventLoop itself is !Send and !Sync due to underlying platform restrictions. However, EventLoopWindowTarget and [Window] are both not only SendandSync`, but also cheaply clonable. This means that you can create a window on one thread, and then send it to another thread to be used.

Implementations§

source§

impl EventLoop

source§

impl EventLoop

source

pub fn window_target(&self) -> &EventLoopWindowTarget

Manually get a reference to the event loop’s window target.

source

pub fn block_on(self, future: impl Future<Output = Infallible> + 'static) -> !

Block on a future forever.

Methods from Deref<Target = EventLoopWindowTarget>§

source

pub fn set_exit(&self)

Request that the event loop exit as soon as possible.

source

pub fn set_exit_with_code(&self, code: i32)

Request that we exit as soon as possible with the given exit code.

source

pub async fn exit(&self) -> !

Exit the program.

source

pub async fn exit_with_code(&self, code: i32) -> !

Exit the program with the given exit code.

source

pub fn resumed(&self) -> &Handler<()>

Get the handler for the Resumed event.

source

pub fn suspended(&self) -> &Handler<()>

Get the handler for the Suspended event.

source

pub async fn primary_monitor(&self) -> Option<MonitorHandle>

Get the primary monitor.

source

pub async fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle>

Get the available monitors.

source

pub async fn set_device_event_filter(&self, filter: DeviceEventFilter)

Set the device event filter.

Trait Implementations§

source§

impl Debug for EventLoop

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for EventLoop

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Deref for EventLoop

§

type Target = EventLoopWindowTarget

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for EventLoop

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl EventLoopExtRunReturn for EventLoop

source§

fn block_on_return<F>(&mut self, fut: F) -> ReturnOrFinish<i32, F::Output>where F: Future,

Initializes the winit event loop. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.