Skip to main content

Reader

Struct Reader 

Source
pub struct Reader<'a, B: Blocks> { /* private fields */ }
Expand description

A chain opened for reading.

Holding one means the directory has been read, so every chunk after that is a single fetch. That is the whole reason this is a type rather than a function taking a Chain: an enumeration that walks a spilled collection reads the directory once and not once per chunk.

Implementations§

Source§

impl<'a, B: Blocks> Reader<'a, B>

Source

pub fn open(blocks: &'a B, chain: Chain) -> Result<Reader<'a, B>>

Read the directory, if there is one, and get ready to fetch chunks.

Source

pub const fn len(&self) -> u64

The value’s length in bytes.

Source

pub const fn is_empty(&self) -> bool

Whether the value has no bytes in it, which is not the same as having no chunks.

Source

pub const fn chunks(&self) -> u64

How many chunks the value is in.

Source

pub fn chunk(&self, i: u64) -> Result<&'a [u8]>

Fetch chunk i, which is one read and never a walk.

Source

pub fn range(&self, from: u64, to: u64) -> Pieces<'a, '_, B>

Walk the pieces of from .. to, in order, without touching a chunk the range does not reach.

This is what GETRANGE on a spilled value wants, and what a membership test on a spilled collection wants, and they are the same walk. A range inside one chunk is one fetch whatever the value’s size is.

Auto Trait Implementations§

§

impl<'a, B> Freeze for Reader<'a, B>
where &'a B: Freeze,

§

impl<'a, B> RefUnwindSafe for Reader<'a, B>

§

impl<'a, B> Send for Reader<'a, B>
where &'a B: Send,

§

impl<'a, B> Sync for Reader<'a, B>
where &'a B: Sync,

§

impl<'a, B> Unpin for Reader<'a, B>
where &'a B: Unpin,

§

impl<'a, B> UnsafeUnpin for Reader<'a, B>

§

impl<'a, B> UnwindSafe for Reader<'a, B>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.