|
|
|
@ -7,6 +7,7 @@ pub struct ItemsIter<'a, T: Clone + for<'de> Deserialize<'de>> { |
|
|
|
|
page: Page<'a, T>, |
|
|
|
|
buffer: Vec<T>, |
|
|
|
|
cur_idx: usize, |
|
|
|
|
cur_page: usize, |
|
|
|
|
use_initial: bool, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -16,6 +17,7 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>> ItemsIter<'a, T> { |
|
|
|
|
page, |
|
|
|
|
buffer: vec![], |
|
|
|
|
cur_idx: 0, |
|
|
|
|
cur_page: 0, |
|
|
|
|
use_initial: true, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -36,12 +38,17 @@ impl<'a, T: Clone + for<'de> Deserialize<'de>> ItemsIter<'a, T> { |
|
|
|
|
} |
|
|
|
|
self.buffer = items; |
|
|
|
|
self.cur_idx = 0; |
|
|
|
|
self.cur_page += 1; |
|
|
|
|
Some(()) |
|
|
|
|
} else { |
|
|
|
|
None |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn page_num(&self) -> usize { |
|
|
|
|
self.cur_page |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub async fn next_item(&mut self) -> Option<T> { |
|
|
|
|
if self.use_initial { |
|
|
|
|
if self.page.initial_items.is_empty() || self.cur_idx == self.page.initial_items.len() { |
|
|
|
|