Iterator for CompressedCRDTOperationsPerModel

This commit is contained in:
Arnab Chakraborty 2024-09-06 21:01:54 -04:00
parent 0ac38b6845
commit 02e4bf4d5b
2 changed files with 10 additions and 2 deletions

2
Cargo.lock generated
View File

@ -4310,7 +4310,7 @@ dependencies = [
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core 0.51.1",
"windows-core 0.52.0",
]
[[package]]

View File

@ -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<CompressedCRDTOperation>)>;
@ -191,6 +191,14 @@ impl CompressedCRDTOperationsPerModel {
}
}
impl Iterator for CompressedCRDTOperationsPerModel {
type Item = (ModelId, CompressedCRDTOperationsPerRecord);
fn next(&mut self) -> Option<Self::Item> {
self.0.pop()
}
}
#[derive(PartialEq, Serialize, Deserialize, Clone, Debug)]
pub struct CompressedCRDTOperation {
pub timestamp: NTP64,