Stub database stream size_hint(); use proper accessor methods for cursor state.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-03-01 22:42:30 +00:00
parent d959dd740f
commit 357a5b7a74
5 changed files with 61 additions and 15 deletions

View File

@@ -24,10 +24,16 @@ impl<'a> Cursor<'a, KeyVal<'a>> for ItemsRev<'a> {
fn state(&self) -> &State<'a> { &self.state }
#[inline]
fn fetch(&self) -> Option<KeyVal<'a>> { self.state.fetch().map(keyval_longevity) }
fn state_mut(&mut self) -> &mut State<'a> { &mut self.state }
#[inline]
fn seek(&mut self) { self.state.seek_rev(); }
fn count(&self) -> (usize, Option<usize>) { self.state().count_rev() }
#[inline]
fn fetch(&self) -> Option<KeyVal<'a>> { self.state().fetch().map(keyval_longevity) }
#[inline]
fn seek(&mut self) { self.state_mut().seek_rev(); }
}
impl<'a> Stream for ItemsRev<'a> {
@@ -36,9 +42,11 @@ impl<'a> Stream for ItemsRev<'a> {
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Poll::Ready(self.seek_and_get())
}
fn size_hint(&self) -> (usize, Option<usize>) { self.count() }
}
impl FusedStream for ItemsRev<'_> {
#[inline]
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
fn is_terminated(&self) -> bool { !self.state().init && !self.state().valid() }
}