iced_native/system/
action.rs1use crate::system;
2
3use iced_futures::MaybeSend;
4use std::fmt;
5
6pub enum Action<T> {
8 QueryInformation(Box<dyn Closure<T>>),
10}
11
12pub trait Closure<T>: Fn(system::Information) -> T + MaybeSend {}
13
14impl<T, O> Closure<O> for T where T: Fn(system::Information) -> O + MaybeSend {}
15
16impl<T> Action<T> {
17 pub fn map<A>(
19 self,
20 f: impl Fn(T) -> A + 'static + MaybeSend + Sync,
21 ) -> Action<A>
22 where
23 T: 'static,
24 {
25 match self {
26 Self::QueryInformation(o) => {
27 Action::QueryInformation(Box::new(move |s| f(o(s))))
28 }
29 }
30 }
31}
32
33impl<T> fmt::Debug for Action<T> {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 match self {
36 Self::QueryInformation(_) => write!(f, "Action::QueryInformation"),
37 }
38 }
39}