Skip to main content

MessageLoop

Struct MessageLoop 

Source
pub struct MessageLoop { /* private fields */ }
Expand description

Abstract representation of a message loop.

Not directly constructible. Use MessageLoop::run to create a message loop. The message loop struct is used to control message loop behavior by passing it as an argument to the filter closure of MessageLoop::run.

Implementations§

Source§

impl MessageLoop

Source

pub fn run(filter: impl Fn(&MessageLoop, &MSG) -> FilterResult)

Runs the message loop with a filter closure to inspect and drop messages before they are dispatched to their respective window procedures.

Use the FilterResult return value to control how the message is handled. The first argument to the filter closure is the MessageLoop struct itself, which can be used to quit the message loop.

Like block_on(), this function runs any tasks spawned from the same thread using spawn_local(). All tasks are suspended when this function returns.

Installs a WH_MSGFILTER hook to allow inspection of messages while modal windows are open.

§Panics and Reentrancy

Panics if called from within another MessageLoop::run() filter closure.

A call to block_on() from within the filter closure creates a nested message loop, which causes the filter closure to be re-entered when a modal window is open.

Source

pub fn quit(&self)

Quits the message loop as soon as possible.

Source

pub fn quit_when_idle(&self)

Quits the message loop when there are no more messages to process.

Auto Trait Implementations§

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<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.