Struct EventLoop

Source
pub struct EventLoop<TS: ThreadSafety = DefaultThreadSafety> { /* 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<TS: ThreadSafety> EventLoop<TS>

Source§

impl<TS: ThreadSafety + 'static> EventLoop<TS>

Source

pub fn window_target(&self) -> &EventLoopWindowTarget<TS>

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<TS>>§

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<(), TS>

Get the handler for the Resumed event.

Source

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

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<TS: ThreadSafety> Debug for EventLoop<TS>

Source§

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

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

impl<TS: ThreadSafety> Default for EventLoop<TS>

Source§

fn default() -> Self

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

impl<TS: ThreadSafety> Deref for EventLoop<TS>

Source§

type Target = EventLoopWindowTarget<TS>

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<TS: ThreadSafety> DerefMut for EventLoop<TS>

Source§

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

Mutably dereferences the value.
Source§

impl<TS: ThreadSafety> EventLoopExtRunReturn for EventLoop<TS>

Source§

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

Initializes the winit event loop. Read more
Source§

impl<TS: ThreadSafety> HasRawDisplayHandle for EventLoop<TS>

Auto Trait Implementations§

§

impl<TS = ThreadUnsafe> !Freeze for EventLoop<TS>

§

impl<TS = ThreadUnsafe> !RefUnwindSafe for EventLoop<TS>

§

impl<TS = ThreadUnsafe> !Send for EventLoop<TS>

§

impl<TS = ThreadUnsafe> !Sync for EventLoop<TS>

§

impl<TS> Unpin for EventLoop<TS>
where <TS as __ThreadSafety>::Rc<Reactor<TS>>: Unpin,

§

impl<TS = ThreadUnsafe> !UnwindSafe for EventLoop<TS>

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.