Struct MainContext
pub struct MainContext { /* private fields */ }Expand description
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
§impl MainContext
impl MainContext
pub fn as_ptr(&self) -> *mut GMainContext
pub fn as_ptr(&self) -> *mut GMainContext
Return the inner pointer to the underlying C value.
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GMainContext) -> &MainContext
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut GMainContext) -> &MainContext
Borrows the underlying C value.
§impl MainContext
impl MainContext
pub fn new() -> MainContext
pub fn with_flags(flags: MainContextFlags) -> MainContext
pub fn dispatch(&self)
pub fn is_owner(&self) -> bool
pub fn iteration(&self, may_block: bool) -> bool
pub fn pending(&self) -> bool
pub fn wakeup(&self)
pub fn default() -> MainContext
pub fn thread_default() -> Option<MainContext>
pub fn ref_thread_default() -> MainContext
§impl MainContext
impl MainContext
pub fn prepare(&self) -> (bool, i32)
pub fn find_source_by_id(&self, source_id: &SourceId) -> Option<Source>
pub fn invoke<F>(&self, func: F)
pub fn invoke<F>(&self, func: F)
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.
pub fn invoke_with_priority<F>(&self, priority: Priority, func: F)
pub fn invoke_with_priority<F>(&self, priority: Priority, func: F)
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.
pub fn invoke_local<F>(&self, func: F)where
F: FnOnce() + 'static,
pub fn invoke_local<F>(&self, func: F)where
F: FnOnce() + 'static,
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.
pub fn invoke_local_with_priority<F>(&self, _priority: Priority, func: F)where
F: FnOnce() + 'static,
pub fn invoke_local_with_priority<F>(&self, _priority: Priority, func: F)where
F: FnOnce() + 'static,
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.
pub fn with_thread_default<R, F>(&self, func: F) -> Result<R, BoolError>where
F: FnOnce() -> R,
pub fn with_thread_default<R, F>(&self, func: F) -> Result<R, BoolError>where
F: FnOnce() -> R,
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.
pub fn acquire(&self) -> Result<MainContextAcquireGuard<'_>, BoolError>
pub fn acquire(&self) -> Result<MainContextAcquireGuard<'_>, BoolError>
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.
§impl MainContext
impl MainContext
pub fn spawn<R, F>(&self, f: F) -> JoinHandle<R> ⓘ
pub fn spawn<R, F>(&self, f: F) -> JoinHandle<R> ⓘ
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.
pub fn spawn_local<R, F>(&self, f: F) -> JoinHandle<R> ⓘwhere
R: 'static,
F: Future<Output = R> + 'static,
pub fn spawn_local<R, F>(&self, f: F) -> JoinHandle<R> ⓘwhere
R: 'static,
F: Future<Output = R> + 'static,
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.
pub fn spawn_with_priority<R, F>(
&self,
priority: Priority,
f: F,
) -> JoinHandle<R> ⓘ
pub fn spawn_with_priority<R, F>( &self, priority: Priority, f: F, ) -> JoinHandle<R> ⓘ
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.
pub fn spawn_local_with_priority<R, F>(
&self,
priority: Priority,
f: F,
) -> JoinHandle<R> ⓘwhere
R: 'static,
F: Future<Output = R> + 'static,
pub fn spawn_local_with_priority<R, F>(
&self,
priority: Priority,
f: F,
) -> JoinHandle<R> ⓘwhere
R: 'static,
F: Future<Output = R> + 'static,
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.
pub fn spawn_from_within<R, F>(
&self,
func: impl FnOnce() -> F + Send + 'static,
) -> SpawnWithinJoinHandle<R> ⓘ
pub fn spawn_from_within<R, F>( &self, func: impl FnOnce() -> F + Send + 'static, ) -> SpawnWithinJoinHandle<R> ⓘ
Spawn a new infallible Future on the main context from inside the main context.
The given Future does not have to be Send but the closure to spawn it has to be.
This can be called only from any thread.
pub fn spawn_from_within_with_priority<R, F>(
&self,
priority: Priority,
func: impl FnOnce() -> F + Send + 'static,
) -> SpawnWithinJoinHandle<R> ⓘ
pub fn spawn_from_within_with_priority<R, F>( &self, priority: Priority, func: impl FnOnce() -> F + Send + 'static, ) -> SpawnWithinJoinHandle<R> ⓘ
Spawn a new infallible Future on the main context from inside the main context.
The given Future does not have to be Send but the closure to spawn it has to be.
This can be called only from any thread.
pub fn block_on<F>(&self, f: F) -> <F as Future>::Outputwhere
F: Future,
pub fn block_on<F>(&self, f: F) -> <F as Future>::Outputwhere
F: Future,
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§
§impl Clone for MainContext
impl Clone for MainContext
§fn clone(&self) -> MainContext
fn clone(&self) -> MainContext
Makes a clone of this shared reference.
This increments the strong reference count of the reference. Dropping the reference will decrement it again.
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for MainContext
impl Debug for MainContext
§impl Default for MainContext
impl Default for MainContext
§fn default() -> MainContext
fn default() -> MainContext
§impl From<MainContext> for Value
impl From<MainContext> for Value
§fn from(s: MainContext) -> Value
fn from(s: MainContext) -> Value
§impl HasParamSpec for MainContext
impl HasParamSpec for MainContext
type ParamSpec = ParamSpecBoxed
§type SetValue = MainContext
type SetValue = MainContext
type BuilderFn = fn(&str) -> ParamSpecBoxedBuilder<'_, MainContext>
fn param_spec_builder() -> <MainContext as HasParamSpec>::BuilderFn
§impl Hash for MainContext
impl Hash for MainContext
§impl LocalSpawn for MainContext
impl LocalSpawn for MainContext
§impl Ord for MainContext
impl Ord for MainContext
§impl PartialEq for MainContext
impl PartialEq for MainContext
§impl PartialOrd for MainContext
impl PartialOrd for MainContext
§impl Spawn for MainContext
impl Spawn for MainContext
§impl StaticType for MainContext
impl StaticType for MainContext
§fn static_type() -> Type
fn static_type() -> Type
Self.impl Eq for MainContext
impl Send for MainContext
impl StructuralPartialEq for MainContext
impl Sync for MainContext
Auto Trait Implementations§
impl Freeze for MainContext
impl RefUnwindSafe for MainContext
impl Unpin for MainContext
impl UnwindSafe for MainContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GList) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *const GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(_: *const GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(_: *const GSList) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T>
§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T>
unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<Sp> LocalSpawnExt for Spwhere
Sp: LocalSpawn + ?Sized,
impl<Sp> LocalSpawnExt for Spwhere
Sp: LocalSpawn + ?Sized,
§fn spawn_local<Fut>(&self, future: Fut) -> Result<(), SpawnError>
fn spawn_local<Fut>(&self, future: Fut) -> Result<(), SpawnError>
() to
completion. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Property for Twhere
T: HasParamSpec,
impl<T> Property for Twhere
T: HasParamSpec,
§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
§impl<Sp> SpawnExt for Spwhere
Sp: Spawn + ?Sized,
impl<Sp> SpawnExt for Spwhere
Sp: Spawn + ?Sized,
§fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError>
() to
completion. Read more§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
§fn ensure_type()
fn ensure_type()
§impl<T> ToSendValue for T
impl<T> ToSendValue for T
§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue clone of self.