Skip to main content

a3s_vec/
iterator.rs

1//! Snapshot-isolated document iterator.
2
3use crate::doc::Doc;
4use crate::error::Result;
5
6#[derive(Debug, Clone)]
7pub struct DocIterator {
8    docs: std::vec::IntoIter<Doc>,
9    revision: u64,
10}
11
12impl DocIterator {
13    pub(crate) fn new(docs: Vec<Doc>, revision: u64) -> Self {
14        Self {
15            docs: docs.into_iter(),
16            revision,
17        }
18    }
19    pub fn revision(&self) -> u64 {
20        self.revision
21    }
22}
23
24impl Iterator for DocIterator {
25    type Item = Result<Doc>;
26
27    fn next(&mut self) -> Option<Self::Item> {
28        self.docs.next().map(Ok)
29    }
30}