pytauri_core/ext_mod_impl/lib/
theme.rs1use pyo3::prelude::*;
2
3macro_rules! theme_impl {
4 ($ident:ident => : $($variant:ident),*) => {
5 #[pyclass(frozen, eq, eq_int)]
7 #[derive(PartialEq, Clone, Copy)]
8 #[non_exhaustive]
9 pub enum $ident {
10 $($variant,)*
11 _NonExhaustive,
12 }
13
14 impl From<tauri::Theme> for $ident {
15 fn from(val: tauri::Theme) -> Self {
16 match val {
17 $(tauri::Theme::$variant => $ident::$variant,)*
18 _ => { $ident::_NonExhaustive }
19 }
20 }
21 }
22
23 impl From<$ident> for tauri::Theme {
24 fn from(val: $ident) -> Self {
25 match val {
26 $($ident::$variant => tauri::Theme::$variant,)*
27 $ident::_NonExhaustive => panic!("NonExhaustive is reserved for `#[non_exhaustive]`"),
28 }
29 }
30 }
31 };
32}
33
34theme_impl!(Theme => : Light, Dark);