[−][src]Struct browser_window::application::ApplicationHandleThreaded
A thread-safe application handle. This handle also allows you to dispatch code to be executed on the GUI thread from any other thread.
Implementations
impl ApplicationHandleThreaded
[src]
pub fn delegate<'a, F, R>(&self, func: F) -> ApplicationDelegateFuture<'a, R> where
F: FnOnce(ApplicationHandle) -> R + Send + 'a,
R: Send,
[src]
F: FnOnce(ApplicationHandle) -> R + Send + 'a,
R: Send,
Executes the given closure func
on the GUI thread, and gives back the result when done.
This only works when the runtime is still running.
If the closure panicked, or the runtime is not running, this will return an error.
The function signature is practically the same as:
pub async fn delegate<'a,F,R>( &self, func: F ) -> Result<R, DelegateError> where F: FnOnce( ApplicationHandle ) -> R + Send + 'a, R: Send { /* ... */ }
Keep in mind that in multi-threaded environments, it is generally a good idea to put the output on the heap. The output value will be copied.
Example
let my_value: String = app.delegate(|handle| { "String".to_owned() }).unwrap();
pub fn delegate_future<F, R>(&self, future: F) -> DelegateFutureFuture<'_, R>ⓘNotable traits for DelegateFutureFuture<'a, R>
impl<'a, R> Future for DelegateFutureFuture<'a, R> where
R: Send, type Output = Result<R, DelegateError>;
where
F: Future<Output = R> + 'static,
R: Send + 'static,
[src]
Notable traits for DelegateFutureFuture<'a, R>
impl<'a, R> Future for DelegateFutureFuture<'a, R> where
R: Send, type Output = Result<R, DelegateError>;
F: Future<Output = R> + 'static,
R: Send + 'static,
Executes the given future
on the GUI thread, and gives back its output when done.
This only works when the runtime is still running.
If the future panicked during a poll, or the runtime is not running, this will return an error.
See also delegate
.
The function signature is practically the same as:
pub async fn delegate_future<'a,F,R>( &self, func: F ) -> Result<R, DelegateError> where F: Future<Output=R> + 'static,, R: Send { /* ... */ }
Example
let my_value: String = app.delegate_future(async { "String".to_owned() }).unwrap();
pub fn delegate_async<'a, C, F, R>(
&self,
func: C
) -> DelegateFutureFuture<'a, R>ⓘNotable traits for DelegateFutureFuture<'a, R>
impl<'a, R> Future for DelegateFutureFuture<'a, R> where
R: Send, type Output = Result<R, DelegateError>;
where
C: FnOnce(ApplicationHandle) -> F + Send + 'a,
F: Future<Output = R>,
R: Send + 'static,
[src]
&self,
func: C
) -> DelegateFutureFuture<'a, R>ⓘ
Notable traits for DelegateFutureFuture<'a, R>
impl<'a, R> Future for DelegateFutureFuture<'a, R> where
R: Send, type Output = Result<R, DelegateError>;
C: FnOnce(ApplicationHandle) -> F + Send + 'a,
F: Future<Output = R>,
R: Send + 'static,
Executes the given async closure func
on the GUI thread, and gives back the result when done.
This only works when the runtime is still running.
If the closure panicked, or the runtime is not running, this will return an error.
Except, async closures are not yet supported in stable Rust. What we actually mean are closures of the form:
|handle| async move { /* ... */ }
The function signature is practically the same as:
pub async fn delegate_async<'a,C,F,R>( &self, func: C ) -> Result<R, DelegateError> where C: FnOnce( ApplicationHandle ) -> F + Send + 'a, F: Future<Output=R>, R: Send + 'static { /* ... */ }
Example
let my_value: String = app.delegate_async(|handle| async move { "String".to_owned() }).unwrap();
pub fn dispatch<'a, F>(&self, func: F) -> bool where
F: FnOnce(ApplicationHandle) + Send + 'a,
[src]
F: FnOnce(ApplicationHandle) + Send + 'a,
Queues the given closure func
to be executed on the GUI thread somewhere in the future.
The closure will only execute when and if the runtime is still running.
Returns whether or not the closure will be able to execute.
pub fn dispatch_async<'a, C, F>(&self, func: C) -> bool where
C: FnOnce(ApplicationHandle) -> F + Send + 'a,
F: Future<Output = ()> + 'static,
[src]
C: FnOnce(ApplicationHandle) -> F + Send + 'a,
F: Future<Output = ()> + 'static,
Queues the given async closure func
to be executed on the GUI thread somewhere in the future.
The closure will only execute when and if the runtime is still running.
However, there is no guarantee that the whole closure will execute.
The runtime might exit when the given closure is at a point of waiting.
Returns whether or not the closure will be able to execute its first part.
pub fn exit(&self, exit_code: i32)
[src]
Signals the runtime to exit.
This will cause Runtime::run
to stop and return the provided exit code.
pub fn spawn<F>(&self, future: F) where
F: Future<Output = ()> + 'static,
[src]
F: Future<Output = ()> + 'static,
Executes the given future on the GUI thread somewhere in the near future.
Trait Implementations
impl Clone for ApplicationHandleThreaded
[src]
fn clone(&self) -> ApplicationHandleThreaded
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ApplicationHandleThreaded
[src]
impl From<ApplicationHandle> for ApplicationHandleThreaded
[src]
fn from(other: ApplicationHandle) -> Self
[src]
impl Send for ApplicationHandleThreaded
[src]
impl Sync for ApplicationHandleThreaded
[src]
Auto Trait Implementations
impl RefUnwindSafe for ApplicationHandleThreaded
impl Unpin for ApplicationHandleThreaded
impl UnwindSafe for ApplicationHandleThreaded
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,