1pub mod shared;
24pub use shared::Shared;
25
26pub mod list;
27pub use list::{List, ListEntry};
28
29#[doc(hidden)]
30pub mod r#struct;
31
32#[doc(hidden)]
33pub mod reexported {
34 pub use dioxus_core::Scope;
35 pub use parking_lot::Mutex;
36 pub use paste::paste;
37}
38
39#[doc(hidden)]
40mod sealed {
41 pub trait Flag {
42 const READ: bool;
43 }
44
45 pub trait InductiveMarkerTuple {
46 type __Base;
47 type __Step;
48 type __Decons;
49 fn __base(&self) -> Self::__Base;
50 fn __step(&self) -> Self::__Step;
51 }
52 macro_rules! impl_InductiveMarkerTuple_for {
53 () => {};
54 ($T:ident$($(,$U:ident$({$ct:tt})?)+)?) => {
55 impl<$T: Copy$($(,$U: Copy)+)?> InductiveMarkerTuple for ($($($U,)+)?$T,) {
56 type __Base = ($($($U,)+)?);
57 type __Step = $T;
58 type __Decons = super::Decons<Self::__Base, Self::__Step>;
59 fn __base(&self) -> Self::__Base {
60 paste::paste! {
61 let ($($([<__ $U:lower>],)+)?_,) = *self;
62 $(($([<__ $U:lower>],)+))?
63 }
64 }
65 fn __step(&self) -> Self::__Step {
66 let ($($(_ $($ct)?,)+)?r,) = *self;
67 r
68 }
69 }
70 impl_InductiveMarkerTuple_for! ($($($U),+)?);
71 }
72 }
73 impl_InductiveMarkerTuple_for!(
74 AA, AB, AC, AD, AE, AF, AG, AH, AI, AJ, AK, AL, AM, AN, AO, AP, AQ, AR, AS, AT, AU, AV, AW,
75 AX, AY, AZ, BA, BB, BC, BD, BE, BF, BG, BH, BI, BJ, BK, BL, BM, BN, BO, BP, BQ, BR, BS, BT,
76 BU, BV, BW, BX, BY, BZ
77 );
78
79 pub trait InitType: Sized + Copy {
80 fn __init_field<P, T, S: crate::shared::Static<Type = T>>(
81 cx: &dioxus_core::Scope<P>,
82 _: &mut Option<crate::shared::Shared<T, Self>>,
83 _: S,
84 );
85 fn __share_field<T, S: crate::shared::Static<Type = T>>(
86 _: &mut Option<crate::Shared<T, Self>>,
87 _: S,
88 );
89 }
90 impl InitType for () {
91 fn __init_field<P, T, S: crate::shared::Static<Type = T>>(
92 _: &dioxus_core::Scope<P>,
93 _: &mut Option<crate::Shared<T, Self>>,
94 _: S,
95 ) {
96 }
97 fn __share_field<T, S: crate::shared::Static<Type = T>>(
98 _: &mut Option<crate::Shared<T, Self>>,
99 _: S,
100 ) {
101 }
102 }
103}
104pub trait Flag: sealed::Flag {}
109impl<T: sealed::Flag> Flag for T {}
110
111pub trait InitType: sealed::InitType {
116 #[doc(hidden)]
117 fn init_field<P, T, S: shared::Static<Type = T>>(
118 cx: &dioxus_core::Scope<P>,
119 f: &mut Option<Shared<T, Self>>,
120 s: S,
121 ) {
122 Self::__init_field(cx, f, s)
123 }
124 #[doc(hidden)]
125 fn share_field<T, S: crate::shared::Static<Type = T>>(
126 f: &mut Option<crate::Shared<T, Self>>,
127 s: S,
128 ) {
129 Self::__share_field(f, s)
130 }
131}
132impl<T: sealed::InitType> InitType for T {}
133
134#[derive(Clone, Copy)]
138pub struct W;
139impl sealed::Flag for W {
140 const READ: bool = false;
141}
142impl sealed::InitType for W {
143 fn __init_field<P, T, S: shared::Static<Type = T>>(
144 _: &dioxus_core::Scope<P>,
145 f: &mut Option<Shared<T, Self>>,
146 s: S,
147 ) {
148 if f.is_none() {
149 *f = Some(s._share());
150 }
151 }
152 fn __share_field<T, S: crate::shared::Static<Type = T>>(
153 f: &mut Option<crate::Shared<T, Self>>,
154 s: S,
155 ) {
156 if f.is_none() {
157 *f = Some(s._share());
158 }
159 }
160}
161
162#[derive(Clone, Copy)]
167pub struct RW;
168impl sealed::Flag for RW {
169 const READ: bool = true;
170}
171impl sealed::InitType for RW {
172 fn __init_field<P, T, S: shared::Static<Type = T>>(
173 cx: &dioxus_core::Scope<P>,
174 f: &mut Option<Shared<T, Self>>,
175 s: S,
176 ) {
177 if f.is_none() {
178 let id = cx.scope_id().0;
179 let mut r = s._share();
180 r.id = Some(id);
181 r.link.add_listener(id, || cx.schedule_update());
182 *f = Some(unsafe { std::mem::transmute(r) });
185 }
186 }
187 fn __share_field<T, S: crate::shared::Static<Type = T>>(
188 _: &mut Option<crate::Shared<T, Self>>,
189 _: S,
190 ) {
191 unreachable!()
192 }
193}
194
195#[doc(hidden)]
196pub trait InductiveMarkerTuple: sealed::InductiveMarkerTuple {
197 type Base;
198 type Step;
199 type Decons;
200 fn base(&self) -> Self::Base;
201 fn step(&self) -> Self::Step;
202}
203impl<T: sealed::InductiveMarkerTuple> InductiveMarkerTuple for T {
204 type Base = T::__Base;
205 type Step = T::__Step;
206 type Decons = T::__Decons;
207 fn base(&self) -> Self::Base {
208 self.__base()
209 }
210 fn step(&self) -> Self::Step {
211 self.__step()
212 }
213}
214#[doc(hidden)]
215pub struct Decons<T, U>(T, U);