#[repr(transparent)]
pub struct MainContext { /* private fields */ }

Implementations

Invokes func on the main context.

If the current thread is the owner of the main context or the main context currently has no owner then func will be called directly from inside this function. If this behaviour is not desired and func should always be called asynchronously then use MainContext::spawn glib::idle_add instead.

Invokes func on the main context with the given priority.

If the current thread is the owner of the main context or the main context currently has no owner then func will be called directly from inside this function. If this behaviour is not desired and func should always be called asynchronously then use MainContext::spawn glib::idle_add instead.

Invokes func on the main context.

Different to invoke(), this does not require func to be Send but can only be called from the thread that owns the main context.

This function panics if called from a different thread than the one that owns the main context.

Note that this effectively means that func is called directly from inside this function or otherwise panics immediately. If this behaviour is not desired and func should always be called asynchronously then use MainContext::spawn_local glib::idle_add_local instead.

Invokes func on the main context with the given priority.

Different to invoke_with_priority(), this does not require func to be Send but can only be called from the thread that owns the main context.

This function panics if called from a different thread than the one that owns the main context.

Note that this effectively means that func is called directly from inside this function or otherwise panics immediately. If this behaviour is not desired and func should always be called asynchronously then use MainContext::spawn_local glib::idle_add_local instead.

Call closure with the main context configured as the thread default one.

The thread default main context is changed in a panic-safe manner before calling func and released again afterwards regardless of whether closure panicked or not.

This will fail if the main context is owned already by another thread.

Acquire ownership of the main context.

Ownership will automatically be released again once the returned acquire guard is dropped.

This will fail if the main context is owned already by another thread.

Creates a channel for a main context.

The Receiver has to be attached to a main context at a later time, together with a closure that will be called for every item sent to a Sender.

The Sender can be cloned and both the Sender and Receiver can be sent to different threads as long as the item type implements the Send trait.

When the last Sender is dropped the channel is removed from the main context. If the Receiver is dropped and not attached to a main context all sending to the Sender will fail.

The returned Sender behaves the same as std::sync::mpsc::Sender.

Creates a synchronous channel for a main context with a given bound on the capacity of the channel.

The Receiver has to be attached to a main context at a later time, together with a closure that will be called for every item sent to a SyncSender.

The SyncSender can be cloned and both the SyncSender and Receiver can be sent to different threads as long as the item type implements the Send trait.

When the last SyncSender is dropped the channel is removed from the main context. If the Receiver is dropped and not attached to a main context all sending to the SyncSender will fail.

The returned SyncSender behaves the same as std::sync::mpsc::SyncSender.

Spawn a new infallible Future on the main context.

This can be called from any thread and will execute the future from the thread where main context is running, e.g. via a MainLoop.

Spawn a new infallible Future on the main context.

The given Future does not have to be Send.

This can be called only from the thread where the main context is running, e.g. from any other Future that is executed on this main context, or after calling with_thread_default or acquire on the main context.

Spawn a new infallible Future on the main context, with a non-default priority.

This can be called from any thread and will execute the future from the thread where main context is running, e.g. via a MainLoop.

Spawn a new infallible Future on the main context, with a non-default priority.

The given Future does not have to be Send.

This can be called only from the thread where the main context is running, e.g. from any other Future that is executed on this main context, or after calling with_thread_default or acquire on the main context.

Runs a new, infallible Future on the main context and block until it finished, returning the result of the Future.

The given Future does not have to be Send or 'static.

This must only be called if no MainLoop or anything else is running on this specific main context.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Spawns a future that will be run to completion. Read more

Determines whether the executor is able to spawn new tasks. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Spawns a future that will be run to completion. Read more

Determines whether the executor is able to spawn new tasks. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Ensures that the type has been registered with the type system.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.