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:
@@ -25,6 +25,10 @@ pub(crate) struct State<'a> {
|
|||||||
pub(crate) trait Cursor<'a, T>: Send {
|
pub(crate) trait Cursor<'a, T>: Send {
|
||||||
fn state(&self) -> &State<'a>;
|
fn state(&self) -> &State<'a>;
|
||||||
|
|
||||||
|
fn state_mut(&mut self) -> &mut State<'a>;
|
||||||
|
|
||||||
|
fn count(&self) -> (usize, Option<usize>);
|
||||||
|
|
||||||
fn fetch(&self) -> Option<T>;
|
fn fetch(&self) -> Option<T>;
|
||||||
|
|
||||||
fn seek(&mut self);
|
fn seek(&mut self);
|
||||||
@@ -111,9 +115,15 @@ impl<'a> State<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn is_incomplete(&self) -> bool {
|
#[inline]
|
||||||
matches!(self.status(), Some(e) if is_incomplete(&e))
|
#[expect(clippy::unused_self)]
|
||||||
}
|
#[tracing::instrument(level = "trace", skip_all, ret)]
|
||||||
|
pub(super) fn count_fwd(&self) -> (usize, Option<usize>) { (0, None) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[expect(clippy::unused_self)]
|
||||||
|
#[tracing::instrument(level = "trace", skip_all, ret)]
|
||||||
|
pub(super) fn count_rev(&self) -> (usize, Option<usize>) { (0, None) }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fetch_key(&self) -> Option<Key<'_>> { self.inner.key() }
|
fn fetch_key(&self) -> Option<Key<'_>> { self.inner.key() }
|
||||||
@@ -124,6 +134,10 @@ impl<'a> State<'a> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn fetch(&self) -> Option<KeyVal<'_>> { self.inner.item() }
|
fn fetch(&self) -> Option<KeyVal<'_>> { self.inner.item() }
|
||||||
|
|
||||||
|
pub(super) fn is_incomplete(&self) -> bool {
|
||||||
|
matches!(self.status(), Some(e) if is_incomplete(&e))
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn status(&self) -> Option<rocksdb::Error> { self.inner.status().err() }
|
pub(super) fn status(&self) -> Option<rocksdb::Error> { self.inner.status().err() }
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ impl<'a> Cursor<'a, KeyVal<'a>> for Items<'a> {
|
|||||||
fn state(&self) -> &State<'a> { &self.state }
|
fn state(&self) -> &State<'a> { &self.state }
|
||||||
|
|
||||||
#[inline]
|
#[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]
|
#[inline]
|
||||||
fn seek(&mut self) { self.state.seek_fwd(); }
|
fn count(&self) -> (usize, Option<usize>) { self.state().count_fwd() }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn fetch(&self) -> Option<KeyVal<'a>> { self.state().fetch().map(keyval_longevity) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn seek(&mut self) { self.state_mut().seek_fwd(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Stream for Items<'a> {
|
impl<'a> Stream for Items<'a> {
|
||||||
@@ -36,9 +42,11 @@ impl<'a> Stream for Items<'a> {
|
|||||||
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
Poll::Ready(self.seek_and_get())
|
Poll::Ready(self.seek_and_get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) { self.count() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FusedStream for Items<'_> {
|
impl FusedStream for Items<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
|
fn is_terminated(&self) -> bool { !self.state().init && !self.state().valid() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ impl<'a> Cursor<'a, KeyVal<'a>> for ItemsRev<'a> {
|
|||||||
fn state(&self) -> &State<'a> { &self.state }
|
fn state(&self) -> &State<'a> { &self.state }
|
||||||
|
|
||||||
#[inline]
|
#[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]
|
#[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> {
|
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>> {
|
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
Poll::Ready(self.seek_and_get())
|
Poll::Ready(self.seek_and_get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) { self.count() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FusedStream for ItemsRev<'_> {
|
impl FusedStream for ItemsRev<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
|
fn is_terminated(&self) -> bool { !self.state().init && !self.state().valid() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ impl<'a> Cursor<'a, Key<'a>> for Keys<'a> {
|
|||||||
fn state(&self) -> &State<'a> { &self.state }
|
fn state(&self) -> &State<'a> { &self.state }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fetch(&self) -> Option<Key<'a>> { self.state.fetch_key().map(slice_longevity) }
|
fn state_mut(&mut self) -> &mut State<'a> { &mut self.state }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn seek(&mut self) { self.state.seek_fwd(); }
|
fn count(&self) -> (usize, Option<usize>) { self.state().count_fwd() }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn fetch(&self) -> Option<Key<'a>> { self.state().fetch_key().map(slice_longevity) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn seek(&mut self) { self.state_mut().seek_fwd(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Stream for Keys<'a> {
|
impl<'a> Stream for Keys<'a> {
|
||||||
@@ -36,9 +42,11 @@ impl<'a> Stream for Keys<'a> {
|
|||||||
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
Poll::Ready(self.seek_and_get())
|
Poll::Ready(self.seek_and_get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) { self.count() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FusedStream for Keys<'_> {
|
impl FusedStream for Keys<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
|
fn is_terminated(&self) -> bool { !self.state().init && !self.state().valid() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,16 @@ impl<'a> Cursor<'a, Key<'a>> for KeysRev<'a> {
|
|||||||
fn state(&self) -> &State<'a> { &self.state }
|
fn state(&self) -> &State<'a> { &self.state }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fetch(&self) -> Option<Key<'a>> { self.state.fetch_key().map(slice_longevity) }
|
fn state_mut(&mut self) -> &mut State<'a> { &mut self.state }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn seek(&mut self) { self.state.seek_rev(); }
|
fn count(&self) -> (usize, Option<usize>) { self.state().count_rev() }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn fetch(&self) -> Option<Key<'a>> { self.state().fetch_key().map(slice_longevity) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn seek(&mut self) { self.state_mut().seek_rev(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Stream for KeysRev<'a> {
|
impl<'a> Stream for KeysRev<'a> {
|
||||||
@@ -36,9 +42,11 @@ impl<'a> Stream for KeysRev<'a> {
|
|||||||
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(mut self: Pin<&mut Self>, _ctx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
Poll::Ready(self.seek_and_get())
|
Poll::Ready(self.seek_and_get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_hint(&self) -> (usize, Option<usize>) { self.count() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FusedStream for KeysRev<'_> {
|
impl FusedStream for KeysRev<'_> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_terminated(&self) -> bool { !self.state.init && !self.state.valid() }
|
fn is_terminated(&self) -> bool { !self.state().init && !self.state().valid() }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user