krishvishal commented on code in PR #2675:
URL: https://github.com/apache/iggy/pull/2675#discussion_r2797917788


##########
core/metadata/src/stm/mux.rs:
##########
@@ -91,7 +92,58 @@ where
     }
 }
 
+/// Recursive case for variadic tuple pattern: (Head, Tail)
+/// Fills snapshot from head and tail, and restores both on restore.
+impl<S, Rest> FillSnapshot for variadic!(S, ...Rest)
+where
+    S: FillSnapshot,
+    Rest: FillSnapshot,
+{
+    fn fill_snapshot(&self, snapshot: &mut MetadataSnapshot) -> Result<(), 
SnapshotError> {
+        self.0.fill_snapshot(snapshot)?;
+        self.1.fill_snapshot(snapshot)?;
+        Ok(())
+    }
+}
+
+impl<S, Rest> RestoreSnapshot for variadic!(S, ...Rest)
+where
+    S: RestoreSnapshot,
+    Rest: RestoreSnapshot,
+{
+    fn restore_snapshot(snapshot: &MetadataSnapshot) -> Result<Self, 
SnapshotError> {
+        let head = S::restore_snapshot(snapshot)?;
+        let tail = Rest::restore_snapshot(snapshot)?;
+        Ok((head, tail))
+    }
+}
+
+impl<T> FillSnapshot for MuxStateMachine<T>
+where
+    T: StateMachine + FillSnapshot,
+{
+    fn fill_snapshot(&self, snapshot: &mut MetadataSnapshot) -> Result<(), 
SnapshotError> {
+        self.inner.fill_snapshot(snapshot)
+    }
+}
+
+impl<T> RestoreSnapshot for MuxStateMachine<T>
+where
+    T: StateMachine + RestoreSnapshot,
+{
+    fn restore_snapshot(snapshot: &MetadataSnapshot) -> Result<Self, 
SnapshotError> {
+        let inner = T::restore_snapshot(snapshot)?;
+        Ok(MuxStateMachine::new(inner))
+    }
+}
+
+#[allow(unused_imports)]
 mod tests {

Review Comment:
   Done created a new test called `roundtrip_with_slab_gaps`. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to