1pub trait PropsBuilder<T> {
2 fn build(self) -> T;
3}
4
5pub trait Props {
6 type InitialBuilder;
7
8 fn init_builder() -> Self::InitialBuilder;
9}
10
11pub struct NoProps;
12
13impl PropsBuilder<NoProps> for NoProps {
14 #[inline]
15 fn build(self) -> NoProps {
16 self
17 }
18}
19
20impl Props for NoProps {
21 type InitialBuilder = NoProps;
22
23 #[inline]
24 fn init_builder() -> Self::InitialBuilder {
25 NoProps
26 }
27}
28
29pub trait UseRender {
30 type RenderArg: Props;
31 type RenderOutput;
39 fn use_render(&self, props: &Self::RenderArg) -> Self::RenderOutput;
40}
41
42pub trait Component {
43 type Props: Props;
44 type Element;
49
50 fn create_element(self, props: Self::Props, key: Option<crate::Key>) -> Self::Element;
51}
52
53pub trait UseRenderStatic {
54 type RenderArg: Props;
55 type RenderOutput;
57 fn use_render(props: &Self::RenderArg) -> Self::RenderOutput;
58}
59
60pub trait ComponentStatic {
61 type Props: Props;
62 type Element;
64
65 fn create_element(props: Self::Props, key: Option<crate::Key>) -> Self::Element;
66}
67
68impl<T: UseRenderStatic> UseRender for T {
69 type RenderArg = <T as UseRenderStatic>::RenderArg;
70 type RenderOutput = <T as UseRenderStatic>::RenderOutput;
71
72 #[inline]
73 fn use_render(&self, props: &Self::RenderArg) -> Self::RenderOutput {
74 T::use_render(props)
75 }
76}
77
78impl<T: ComponentStatic> Component for T {
79 type Props = <T as ComponentStatic>::Props;
80 type Element = <T as ComponentStatic>::Element;
81
82 #[inline]
83 fn create_element(self, props: Self::Props, key: Option<crate::Key>) -> Self::Element {
84 T::create_element(props, key)
85 }
86}