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


##########
core/metadata/src/impls/metadata.rs:
##########
@@ -23,6 +27,114 @@ use journal::{Journal, JournalHandle};
 use message_bus::MessageBus;
 use tracing::{debug, warn};
 
+/// Trait for metadata snapshot implementations.
+///
+/// This is the interface that `MetadataHandle::Snapshot` must satisfy.
+/// It provides methods for creating, encoding, decoding, and restoring 
snapshots.
+#[allow(unused)]
+pub trait MetadataSnapshot: Sized {
+    /// The error type for snapshot operations.
+    type Error: std::error::Error;
+
+    /// Create a snapshot from the current state of the mux state machine.
+    ///
+    /// # Arguments
+    /// * `mux` - The multiplexing state machine containing all sub-state 
machines
+    /// * `commit_number` - The VSR commit number this snapshot corresponds to
+    fn create<T>(mux: &MuxStateMachine<T>, commit_number: u64) -> Result<Self, 
Self::Error>

Review Comment:
   Done.



##########
core/metadata/src/impls/metadata.rs:
##########
@@ -23,6 +27,114 @@ use journal::{Journal, JournalHandle};
 use message_bus::MessageBus;
 use tracing::{debug, warn};
 
+/// Trait for metadata snapshot implementations.
+///
+/// This is the interface that `MetadataHandle::Snapshot` must satisfy.
+/// It provides methods for creating, encoding, decoding, and restoring 
snapshots.
+#[allow(unused)]
+pub trait MetadataSnapshot: Sized {

Review Comment:
   Done.



##########
core/metadata/src/impls/metadata.rs:
##########
@@ -23,6 +27,114 @@ use journal::{Journal, JournalHandle};
 use message_bus::MessageBus;
 use tracing::{debug, warn};
 
+/// Trait for metadata snapshot implementations.
+///
+/// This is the interface that `MetadataHandle::Snapshot` must satisfy.
+/// It provides methods for creating, encoding, decoding, and restoring 
snapshots.
+#[allow(unused)]
+pub trait MetadataSnapshot: Sized {
+    /// The error type for snapshot operations.
+    type Error: std::error::Error;
+
+    /// Create a snapshot from the current state of the mux state machine.
+    ///
+    /// # Arguments
+    /// * `mux` - The multiplexing state machine containing all sub-state 
machines
+    /// * `commit_number` - The VSR commit number this snapshot corresponds to
+    fn create<T>(mux: &MuxStateMachine<T>, commit_number: u64) -> Result<Self, 
Self::Error>
+    where
+        T: StateMachine + SnapshotContributor;
+
+    /// Encode the snapshot to msgpack bytes.
+    fn encode(&self) -> Result<Vec<u8>, Self::Error>;
+
+    /// Decode a snapshot from msgpack bytes.
+    fn decode(bytes: &[u8]) -> Result<Self, Self::Error>;
+
+    /// Restore a mux state machine from this snapshot.
+    fn restore<T>(&self) -> Result<MuxStateMachine<T>, Self::Error>
+    where
+        T: StateMachine + SnapshotContributor;
+
+    /// Get the VSR commit number this snapshot corresponds to.

Review Comment:
   Done.



-- 
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