pub struct PooledIter<I, BorrowedItem: ToOwned> { /* private fields */ }anchored-pool only.Expand description
Convert a CursorLendingIterator into a CursorPooledIterator by storing recently
accessed items in reusable buffers.
This effectively allows the iterator to lend out multiple items at once, unlike a lending iterator which can only lend out one. This comes primarily at the cost of extra copying into buffers, and in memory usage. The costs of allocating buffers is likely amortized by their reuse.
The user of a PooledIter is required not to attempt to get more PoolItems than there
are buffers in the PooledIter; because PooledIter can only be used from a single thread,
it is impossible for a buffer to be returned to the iterator while PooledIter::next
is running, for example, unlike with the ThreadsafePooledIter type. Therefore, PooledIter
panics in such a scenario.
Implementations§
Source§impl<I, BorrowedItem> PooledIter<I, BorrowedItem>
impl<I, BorrowedItem> PooledIter<I, BorrowedItem>
Sourcepub fn new(iter: I, num_buffers: usize) -> Self
pub fn new(iter: I, num_buffers: usize) -> Self
Create a PooledIter that can lend out up to num_buffers items at a time.
The user of a PooledIter is required not to attempt to get more than num_buffers
PoolItems from this PooledIter at a time; because PooledIter can only be used from
a single thread, it is impossible for a buffer to be returned to the iterator while
PooledIter::next is running, for example, unlike with the ThreadsafePooledIter type.
Therefore, PooledIter panics in such a scenario.
Trait Implementations§
Source§impl<I, BorrowedItem> CursorPooledIterator for PooledIter<I, BorrowedItem>where
I: CursorLendingIterator,
BorrowedItem: ToOwned,
for<'lend> LentItem<'lend, I>: Borrow<BorrowedItem>,
impl<I, BorrowedItem> CursorPooledIterator for PooledIter<I, BorrowedItem>where
I: CursorLendingIterator,
BorrowedItem: ToOwned,
for<'lend> LentItem<'lend, I>: Borrow<BorrowedItem>,
Source§fn prev(&mut self) -> Option<Self::Item>
fn prev(&mut self) -> Option<Self::Item>
Move the iterator one position back, and return the entry at that position.
Returns None if the iterator was at the first entry.
Some iterator implementations used as I may have worse performance for backwards
iteration than forwards iteration, so prefer to not use prev.
§Panics
Panics if there are no buffers available.
Source§fn valid(&self) -> bool
fn valid(&self) -> bool
Source§fn try_current(&self) -> Result<Option<Self::Item>, OutOfBuffers>
fn try_current(&self) -> Result<Option<Self::Item>, OutOfBuffers>
Source§impl<I, BorrowedItem> PooledIterator for PooledIter<I, BorrowedItem>where
I: CursorLendingIterator,
BorrowedItem: ToOwned,
for<'lend> LentItem<'lend, I>: Borrow<BorrowedItem>,
impl<I, BorrowedItem> PooledIterator for PooledIter<I, BorrowedItem>where
I: CursorLendingIterator,
BorrowedItem: ToOwned,
for<'lend> LentItem<'lend, I>: Borrow<BorrowedItem>,
Source§fn next(&mut self) -> Option<Self::Item>
fn next(&mut self) -> Option<Self::Item>
Move the iterator one position forwards, and return the entry at that position.
Returns None if the iterator was at the last entry.
§Panics
Panics if there are no buffers available.
Source§type Item = PoolItem<<BorrowedItem as ToOwned>::Owned>
type Item = PoolItem<<BorrowedItem as ToOwned>::Owned>
Source§fn try_next(&mut self) -> Result<Option<Self::Item>, OutOfBuffers>
fn try_next(&mut self) -> Result<Option<Self::Item>, OutOfBuffers>
Ok(None) if the iterator was at the last entry. Read moreSource§fn buffer_pool_size(&self) -> usize
fn buffer_pool_size(&self) -> usize
Source§fn available_buffers(&self) -> usize
fn available_buffers(&self) -> usize
Source§fn into_lender(self) -> PooledLenderAdapter<Self>where
Self: Sized,
fn into_lender(self) -> PooledLenderAdapter<Self>where
Self: Sized,
lender only.PooledIterator into a lender::Lender lending iterator which only uses
one buffer at a time. Read moreSource§fn into_lending_iterator(self) -> PooledLendingIteratorAdapter<Self>where
Self: Sized,
fn into_lending_iterator(self) -> PooledLendingIteratorAdapter<Self>where
Self: Sized,
lending-iterator only.PooledIterator into a lending_iterator::LendingIterator which only uses
one buffer at a time. Read moreSource§impl<I, BorrowedItem, Key, Cmp> Seekable<Key, Cmp> for PooledIter<I, BorrowedItem>where
I: CursorLendingIterator + Seekable<Key, Cmp>,
BorrowedItem: ToOwned,
Key: ?Sized,
Cmp: Comparator<Key>,
for<'lend> LentItem<'lend, I>: Borrow<BorrowedItem>,
impl<I, BorrowedItem, Key, Cmp> Seekable<Key, Cmp> for PooledIter<I, BorrowedItem>where
I: CursorLendingIterator + Seekable<Key, Cmp>,
BorrowedItem: ToOwned,
Key: ?Sized,
Cmp: Comparator<Key>,
for<'lend> LentItem<'lend, I>: Borrow<BorrowedItem>,
Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn seek(&mut self, min_bound: &Key)
fn seek(&mut self, min_bound: &Key)
min_bound. Read moreSource§fn seek_before(&mut self, strict_upper_bound: &Key)
fn seek_before(&mut self, strict_upper_bound: &Key)
strict_upper_bound. Read moreSource§fn seek_to_first(&mut self)
fn seek_to_first(&mut self)
Source§fn seek_to_last(&mut self)
fn seek_to_last(&mut self)
Auto Trait Implementations§
impl<I, BorrowedItem> Freeze for PooledIter<I, BorrowedItem>where
I: Freeze,
impl<I, BorrowedItem> !RefUnwindSafe for PooledIter<I, BorrowedItem>
impl<I, BorrowedItem> !Send for PooledIter<I, BorrowedItem>
impl<I, BorrowedItem> !Sync for PooledIter<I, BorrowedItem>
impl<I, BorrowedItem> Unpin for PooledIter<I, BorrowedItem>where
I: Unpin,
impl<I, BorrowedItem> !UnwindSafe for PooledIter<I, BorrowedItem>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FragileContainer<T> for Twhere
T: ?Sized,
impl<T> FragileContainer<T> for Twhere
T: ?Sized,
Source§fn get_ref(&self) -> <T as FragileTryContainer<T>>::Ref<'_>
fn get_ref(&self) -> <T as FragileTryContainer<T>>::Ref<'_>
Infallibly get immutable access to the T.
Source§impl<T> FragileMutContainer<T> for Twhere
T: ?Sized,
impl<T> FragileMutContainer<T> for Twhere
T: ?Sized,
Source§fn get_mut(&mut self) -> <T as FragileTryMutContainer<T>>::RefMut<'_>
fn get_mut(&mut self) -> <T as FragileTryMutContainer<T>>::RefMut<'_>
Infallibly get mutable access to the T.
Source§impl<T> FragileTryContainer<T> for Twhere
T: ?Sized,
impl<T> FragileTryContainer<T> for Twhere
T: ?Sized,
Source§fn into_inner(self) -> Option<T>
fn into_inner(self) -> Option<T>
Infallibly get the T.
Source§fn try_get_ref(
&self,
) -> Result<<T as FragileTryContainer<T>>::Ref<'_>, <T as FragileTryContainer<T>>::RefError>
fn try_get_ref( &self, ) -> Result<<T as FragileTryContainer<T>>::Ref<'_>, <T as FragileTryContainer<T>>::RefError>
Infallibly get immutable access to the T.
Source§type RefError = Infallible
type RefError = Infallible
try_get_ref. This type should implement
std::error::Error. Read moreSource§fn new_container(t: T) -> T
fn new_container(t: T) -> T
T.Source§impl<T> FragileTryMutContainer<T> for Twhere
T: ?Sized,
impl<T> FragileTryMutContainer<T> for Twhere
T: ?Sized,
Source§fn try_get_mut(
&mut self,
) -> Result<<T as FragileTryMutContainer<T>>::RefMut<'_>, <T as FragileTryMutContainer<T>>::RefMutError>
fn try_get_mut( &mut self, ) -> Result<<T as FragileTryMutContainer<T>>::RefMut<'_>, <T as FragileTryMutContainer<T>>::RefMutError>
Infallibly get mutable access to the T.
Source§type RefMut<'a> = &'a mut T
where
T: 'a
type RefMut<'a> = &'a mut T where T: 'a
Source§type RefMutError = Infallible
type RefMutError = Infallible
try_get_mut. This type should implement
std::error::Error. Read more