shield_dioxus/style.rs
1use std::sync::Arc;
2
3use dioxus::prelude::Element;
4use shield::ActionForms;
5
6pub trait DioxusStyle: Send + Sync {
7 fn render(&self, action: &ActionForms) -> Element;
8}
9
10#[derive(Clone)]
11pub struct ErasedDioxusStyle(Arc<dyn DioxusStyle>);
12
13impl ErasedDioxusStyle {
14 pub fn new<I: DioxusStyle + 'static>(integration: I) -> Self {
15 Self(Arc::new(integration))
16 }
17
18 pub fn render(&self, action: &ActionForms) -> Element {
19 self.0.render(action)
20 }
21}