Struct grenad::ReaderCursor

source ·
pub struct ReaderCursor<R> { /* private fields */ }
Expand description

A cursor that can move forward backward and move on a specified key.

Implementations§

source§

impl<R> ReaderCursor<R>

source

pub fn current(&self) -> Option<(&[u8], &[u8])>

The currently pointed key and value pair.

source

pub fn into_reader(self) -> Reader<R>

Consumes the ReaderCursor and returns the underlying Reader type.

source

pub fn into_inner(self) -> R

Consumes the ReaderCursor and returns the underlying io::Read type.

The returned io::Read type has been io::Seeked which means that you must seek it back to the front to be read from the start.

source

pub fn get_ref(&self) -> &R

Gets a reference to the underlying reader.

source

pub fn reset(&mut self)

Resets the position of the cursor.

Useful when you want to be able to call move_on_next or move_on_prev in a loop and ensure that it will start from the first or the last value of the cursor.

source§

impl<R: Read + Seek> ReaderCursor<R>

source

pub fn move_on_first(&mut self) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the first entry and returns it.

source

pub fn move_on_last(&mut self) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the last entry and returns it.

source

pub fn move_on_next(&mut self) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the entry following the current one and returns it.

source

pub fn move_on_prev(&mut self) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the entry preceding the current one and returns it.

source

pub fn move_on_key_lower_than_or_equal_to<A: AsRef<[u8]>>( &mut self, target_key: A ) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the entry with a key lower than or equal to the specified one and returns the corresponding entry.

source

pub fn move_on_key_greater_than_or_equal_to<A: AsRef<[u8]>>( &mut self, key: A ) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the entry with a key greater than or equal to the specified one and returns the corresponding entry.

source

pub fn move_on_key_equal_to<A: AsRef<[u8]>>( &mut self, key: A ) -> Result<Option<(&[u8], &[u8])>, Error>

Moves the cursor on the entry with a key equal to the key specified and returns the corresponding entry.

Methods from Deref<Target = Reader<R>>§

source

pub fn file_version(&self) -> FileVersion

Returns the version of this file.

source

pub fn compression_type(&self) -> CompressionType

Returns the compression type of this file.

source

pub fn len(&self) -> u64

Returns the number of entries in this file.

source

pub fn is_empty(&self) -> bool

Returns weither this file contains entries or is empty.

source

pub fn get_ref(&self) -> &R

Gets a reference to the underlying reader.

Trait Implementations§

source§

impl<R: Clone> Clone for ReaderCursor<R>

source§

fn clone(&self) -> ReaderCursor<R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R> Deref for ReaderCursor<R>

§

type Target = Reader<R>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<R, MF> Extend<ReaderCursor<R>> for MergerBuilder<R, MF>

source§

fn extend<T: IntoIterator<Item = ReaderCursor<R>>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

§

impl<R> Freeze for ReaderCursor<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ReaderCursor<R>
where R: RefUnwindSafe,

§

impl<R> Send for ReaderCursor<R>
where R: Send,

§

impl<R> Sync for ReaderCursor<R>
where R: Sync,

§

impl<R> Unpin for ReaderCursor<R>
where R: Unpin,

§

impl<R> UnwindSafe for ReaderCursor<R>
where R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.