Skip to main content

iced_runtime/
backend.rs

1//! Configure a [`Backend`](crate::core::Backend) at runtime.
2use crate::Task;
3use crate::core::backend;
4use crate::futures::futures::channel::oneshot;
5use crate::task;
6
7/// An backend operation.
8#[derive(Debug)]
9pub enum Action {
10    /// Switches the [`backend::Settings`] of the current application.
11    Configure(
12        backend::Settings,
13        oneshot::Sender<Result<(), backend::Error>>,
14    ),
15}
16
17/// Returns a [`Task`] that switches the [`backend::Settings`] of the current application.
18///
19/// This can be leveraged to switch renderers at runtime.
20pub fn configure(settings: backend::Settings) -> Task<Result<(), backend::Error>> {
21    task::oneshot(|sender| crate::Action::Backend(Action::Configure(settings, sender)))
22}