summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-06-19 01:53:40 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-06-19 01:53:40 +0200
commit341c9a3c12aa9d327ef1d8f168ea0adb9b5ad10b (patch)
tree6a37f29352b1768911b6d42c220f22ebecc202ee /runtime
parent368b15f70896b387ae3f072e807b289b36b2d103 (diff)
downloadiced-341c9a3c12aa9d327ef1d8f168ea0adb9b5ad10b.tar.gz
iced-341c9a3c12aa9d327ef1d8f168ea0adb9b5ad10b.tar.bz2
iced-341c9a3c12aa9d327ef1d8f168ea0adb9b5ad10b.zip
Introduce `daemon` API and unify shell runtimes
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs
index 5fde3039..b4a5e819 100644
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -70,6 +70,12 @@ pub enum Action<T> {
/// Run a system action.
System(system::Action),
+
+ /// Exits the runtime.
+ ///
+ /// This will normally close any application windows and
+ /// terminate the runtime loop.
+ Exit,
}
impl<T> Action<T> {
@@ -88,6 +94,7 @@ impl<T> Action<T> {
Action::Clipboard(action) => Err(Action::Clipboard(action)),
Action::Window(action) => Err(Action::Window(action)),
Action::System(action) => Err(Action::System(action)),
+ Action::Exit => Err(Action::Exit),
}
}
}
@@ -110,6 +117,15 @@ where
}
Action::Window(_) => write!(f, "Action::Window"),
Action::System(action) => write!(f, "Action::System({action:?})"),
+ Action::Exit => write!(f, "Action::Exit"),
}
}
}
+
+/// Creates a [`Task`] that exits the iced runtime.
+///
+/// This will normally close any application windows and
+/// terminate the runtime loop.
+pub fn exit<T>() -> Task<T> {
+ Task::effect(Action::Exit)
+}