From 02e4bf4d5b926b816179a7ce91865a470053dde8 Mon Sep 17 00:00:00 2001 From: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:01:54 -0400 Subject: [PATCH] `Iterator` for `CompressedCRDTOperationsPerModel` --- Cargo.lock | 2 +- crates/sync/src/compressed.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7064a8a1..b52ae94f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4310,7 +4310,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.51.1", + "windows-core 0.52.0", ] [[package]] diff --git a/crates/sync/src/compressed.rs b/crates/sync/src/compressed.rs index 75bff0165..cf79e5f8f 100644 --- a/crates/sync/src/compressed.rs +++ b/crates/sync/src/compressed.rs @@ -5,7 +5,7 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use uhlc::NTP64; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct CompressedCRDTOperationsPerModel(pub Vec<(ModelId, CompressedCRDTOperationsPerRecord)>); pub type CompressedCRDTOperationsPerRecord = Vec<(RecordId, Vec)>; @@ -191,6 +191,14 @@ impl CompressedCRDTOperationsPerModel { } } +impl Iterator for CompressedCRDTOperationsPerModel { + type Item = (ModelId, CompressedCRDTOperationsPerRecord); + + fn next(&mut self) -> Option { + self.0.pop() + } +} + #[derive(PartialEq, Serialize, Deserialize, Clone, Debug)] pub struct CompressedCRDTOperation { pub timestamp: NTP64,