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>
impl<'a, B: Blocks> Reader<'a, B>
Sourcepub fn open(blocks: &'a B, chain: Chain) -> Result<Reader<'a, B>>
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.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Whether the value has no bytes in it, which is not the same as having no chunks.
Sourcepub fn chunk(&self, i: u64) -> Result<&'a [u8]>
pub fn chunk(&self, i: u64) -> Result<&'a [u8]>
Fetch chunk i, which is one read and never a walk.
Sourcepub fn range(&self, from: u64, to: u64) -> Pieces<'a, '_, B> ⓘ
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.