pub struct Runtime { /* private fields */ }Expand description
Cheaply cloneable handle to the application runtime, providing access to services, the egui context, and the application events channel.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(egui_ctx: &Context, events: Option<ApplicationEventsChannel>) -> Self
pub fn new(egui_ctx: &Context, events: Option<ApplicationEventsChannel>) -> Self
Create a new runtime bound to the given egui context, registering it as the global runtime. An optional application events channel may be supplied, otherwise an unbounded channel is created.
Sourcepub fn bind(&self, service: Arc<dyn Service>)
pub fn bind(&self, service: Arc<dyn Service>)
Register a service with the runtime under its name and immediately spawn its async task.
Sourcepub fn start_services(&self)
pub fn start_services(&self)
Spawn the async task for each bound service.
Sourcepub fn services(&self) -> Vec<Arc<dyn Service>>
pub fn services(&self) -> Vec<Arc<dyn Service>>
Returns a snapshot of all currently bound services.
Sourcepub fn stop_services(&self)
pub fn stop_services(&self)
Request termination of all bound services.
Sourcepub async fn join_services(&self)
pub async fn join_services(&self)
Await the completion of all services’ join futures.
Sourcepub fn repaint_service(&self) -> &Arc<RepaintService> ⓘ
pub fn repaint_service(&self) -> &Arc<RepaintService> ⓘ
Returns the reference to the repaint service driving egui redraws.
Sourcepub fn events(&self) -> &ApplicationEventsChannel
pub fn events(&self) -> &ApplicationEventsChannel
Returns the reference to the application events channel.
Sourcepub async fn send<T>(&self, msg: T) -> Result<()>
pub async fn send<T>(&self, msg: T) -> Result<()>
Send an application even to the UI asynchronously.
Sourcepub async fn send_runtime_event(&self, msg: RuntimeEvent) -> Result<()>
pub async fn send_runtime_event(&self, msg: RuntimeEvent) -> Result<()>
Send a RuntimeEvent to the UI asynchronously.
Sourcepub fn try_send<T>(&self, msg: T) -> Result<()>
pub fn try_send<T>(&self, msg: T) -> Result<()>
Send an application event to the UI synchronously.
Sourcepub fn try_send_runtime_event(&self, msg: RuntimeEvent) -> Result<()>
pub fn try_send_runtime_event(&self, msg: RuntimeEvent) -> Result<()>
Send a RuntimeEvent to the UI synchronously without blocking.
Sourcepub fn spawn_task<F>(&self, task: F)
pub fn spawn_task<F>(&self, task: F)
Spawn an async task on the runtime; if the task returns an error,
it is forwarded to the UI as a RuntimeEvent::Error.
Sourcepub fn spawn_task_with_result<R, F>(
&self,
payload: &Payload<Result<R, Error>>,
task: F,
)
pub fn spawn_task_with_result<R, F>( &self, payload: &Payload<Result<R, Error>>, task: F, )
Spawn an async task whose result is stored into the supplied
Payload. The payload is marked pending while the task runs and
then populated with the Ok or Err outcome on completion.
Sourcepub fn egui_ctx(&self) -> &Context
pub fn egui_ctx(&self) -> &Context
Returns the reference to the egui context bound to this runtime.
Sourcepub fn request_repaint(&self)
pub fn request_repaint(&self)
Request an egui repaint via the repaint service.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Runtime
impl !UnwindSafe for Runtime
impl Freeze for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.