pub fn fetch_entries_to(
        &self,
        begin: u64,
        end: u64,
        max_size: Option<usize>,
        vec_idx: &mut Vec<EntryIndex>,
    ) -> Result<()> {
        if end <= begin {
            return Ok(());
        }
        let len = self.entry_indexes.len();
        if len == 0 {
            return Err(Error::EntryNotFound);
        }
        let first = self.first_index;
        if begin < first {
            return Err(Error::EntryCompacted);
        }
        if end > self.first_index + len as u64 {
            return Err(Error::EntryNotFound);
        }

        let start_pos = (begin - first) as usize;
        let end_pos = (end - begin) as usize + start_pos;

        let mut total_size = 0;
        let mut index = begin;
        for idx in self.entry_indexes.range(start_pos..end_pos) {
            total_size += idx.entry_len;
            // No matter max_size's value, fetch one entry at least.
            if let Some(max_size) = max_size {
                if total_size as usize > max_size && total_size > idx.entry_len {
                    break;
                }
            }
            vec_idx.push(EntryIndex::from_thin(index, *idx));
            index += 1;
        }
        Ok(())
    }
/// Pulls all entries between log index `begin` and `end` to the given
/// buffer. Returns error if any entry is missing.
///
/// When `max_size` is present, stops pulling entries when the total size
/// reaches it.
Pulls all entries between log index `begin` and `end` to the given
buffer. Returns error if any entry is missing.

When `max_size` is present, stops pulling entries when the total size
reaches it.
Pulls all entries between log index ` begin ` and ` end ` to the given buffer . Returns error if any entry is missing . When ` max_size ` is present stops pulling entries when the total size reaches it .
pub fn fetch_entries_to(
        &self,
        begin: u64,
        end: u64,
        max_size: Option<usize>,
        vec_idx: &mut Vec<EntryIndex>,
    ) -> Result<()> {
        if end <= begin {
            return Ok(());
        }
        let len = self.entry_indexes.len();
        if len == 0 {
            return Err(Error::EntryNotFound);
        }
        let first = self.first_index;
        if begin < first {
            return Err(Error::EntryCompacted);
        }
        if end > self.first_index + len as u64 {
            return Err(Error::EntryNotFound);
        }
        let start_pos = (begin - first) as usize;
        let end_pos = (end - begin) as usize + start_pos;
        let mut total_size = 0;
        let mut index = begin;
        for idx in self.entry_indexes.range(start_pos..end_pos) {
            total_size += idx.entry_len;
            // No matter max_size's value, fetch one entry at least.
            if let Some(max_size) = max_size {
                if total_size as usize > max_size && total_size > idx.entry_len {
                    break;
                }
            }
            vec_idx.push(EntryIndex::from_thin(index, *idx));
            index += 1;
        }
        Ok(())
    }
pub fn fetch_entries_to ( & self , begin : u64 , end : u64 , max_size : Option < usize > , vec_idx : & mut Vec < EntryIndex > , ) -> Result < ( ) > { if end <= begin { return Ok ( ( ) ) ; } let len = self . entry_indexes . len ( ) ; if len == 0 { return Err ( Error :: EntryNotFound ) ; } let first = self . first_index ; if begin < first { return Err ( Error :: EntryCompacted ) ; } if end > self . first_index + len as u64 { return Err ( Error :: EntryNotFound ) ; } let start_pos = ( begin - first ) as usize ; let end_pos = ( end - begin ) as usize + start_pos ; let mut total_size = 0 ; let mut index = begin ; for idx in self . entry_indexes . range ( start_pos .. end_pos ) { total_size += idx . entry_len ; // No matter max_size's value, fetch one entry at least. if let Some ( max_size ) = max_size { if total_size as usize > max_size && total_size > idx . entry_len { break ; } } vec_idx . push ( EntryIndex :: from_thin ( index , * idx ) ) ; index += 1 ; } Ok ( ( ) ) }
Pulls all entries between log index `begin` and `end` to the given
buffer.
Pulls all entries between log index ` begin ` and ` end ` to the given buffer .
&self
begin
u64
end
u64
max_size
Option<usize>
vec_idx
&mut Vec<EntryIndex>