src/bisection_tree/bt.rs

branch
dev
changeset 86
d5b0e496b72f
parent 9
f40dfaf2166d
--- a/src/bisection_tree/bt.rs	Mon Dec 30 15:46:28 2024 -0500
+++ b/src/bisection_tree/bt.rs	Mon Jan 06 20:29:25 2025 -0500
@@ -43,7 +43,13 @@
 /// Node of a [`BT`] bisection tree.
 ///
 /// For the type and const parameteres, see the [module level documentation][super].
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(bound(
+    serialize = "NodeOption<F, D, A, N, P> : Serialize,
+                 A : Serialize,",
+    deserialize = "NodeOption<F, D, A, N, P> : for<'a> Deserialize<'a>,
+                   A : for<'a> Deserialize<'a>,"
+))]
 pub struct Node<F : Num, D, A : Aggregator, const N : usize, const P : usize> {
     /// The data or branches under the node.
     pub(super) data : NodeOption<F, D, A, N, P>,
@@ -54,7 +60,13 @@
 /// Branching information of a [`Node`] of a [`BT`] bisection tree into `P` subnodes.
 ///
 /// For the type and const parameters, see the [module level documentation][super].
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize, Deserialize)]
+#[serde(bound(
+    serialize = "[Node<F, D, A, N, P>; P] : Serialize,
+                 Loc<F, N> : Serialize,",
+    deserialize = "[Node<F, D, A, N, P>; P] : for<'a> Deserialize<'a>,
+                   Loc<F, N> : for<'a> Deserialize<'a>,"
+))]
 pub(super) struct Branches<F : Num, D, A : Aggregator, const N : usize, const P : usize> {
     /// Point for subdivision of the (unstored) [`Cube`] corresponding to the node.
     pub(super) branch_at : Loc<F, N>,
@@ -198,6 +210,7 @@
 }
 
 /// An iterator over the $P=2^N$ subcubes of a [`Cube`] subdivided at a point `d`.
+#[derive(Debug, Clone)]
 pub(super) struct SubcubeIter<'b, F : Float, const N : usize, const P : usize> {
     domain : &'b Cube<F, N>,
     branch_at : Loc<F, N>,
@@ -637,7 +650,15 @@
 /// It should be accessed via the [`BTImpl`] trait to hide the `const P : usize` parameter until
 /// const generics are flexible enough to fix `P=pow(2, N)` and thus also get rid of
 /// the `BTNodeLookup : BTNode<F, D, A, N>` trait bound.
-#[derive(Clone,Debug)]
+#[derive(Clone,Debug,Serialize,Deserialize)]
+#[serde(bound(
+    serialize = "Cube<F, N> : Serialize,
+                 M : Serialize,
+                 <BTNodeLookup as BTNode<F, D, A, N>>::Node : Serialize,",
+    deserialize = "Cube<F, N> : for<'a> Deserialize<'a>,
+                   M : for<'a> Deserialize<'a>,
+                   <BTNodeLookup as BTNode<F, D, A, N>>::Node : for<'a> Deserialize<'a>,"
+))]
 pub struct BT<
     M : Depth,
     F : Float,

mercurial