pub fn compact(&mut self, compact_index: u64) -> Result<(), StorageError> {
        let offset = self.ents[0].get_Index();
        if compact_index <= offset {
            return Err(StorageError::Compacted);
        }
        if compact_index > self.last_index().unwrap() {
            unimplemented!(
                "compact {} is out of bound last_index({})",
                compact_index,
                self.last_index().unwrap()
            )
        }
        let i = (compact_index - offset) as usize;
        self.ents.drain(..i);
        Ok(())
    }
// Compact discards all log entries prior to compactIndex.
// It is the application's responsibility to not attempt to compact an index
// greater than raftLog.applied.
Compact discards all log entries prior to compactIndex.
It is the application's responsibility to not attempt to compact an index
greater than raftLog.applied.
Compact discards all log entries prior to compactIndex . It is the application ' s responsibility to not attempt to compact an index greater than raftLog . applied .
pub fn compact(&mut self, compact_index: u64) -> Result<(), StorageError> {
        let offset = self.ents[0].get_Index();
        if compact_index <= offset {
            return Err(StorageError::Compacted);
        }
        if compact_index > self.last_index().unwrap() {
            unimplemented!(
                "compact {} is out of bound last_index({})",
                compact_index,
                self.last_index().unwrap()
            )
        }
        let i = (compact_index - offset) as usize;
        self.ents.drain(..i);
        Ok(())
    }
pub fn compact ( & mut self , compact_index : u64 ) -> Result < ( ) , StorageError > { let offset = self . ents [ 0 ] . get_Index ( ) ; if compact_index <= offset { return Err ( StorageError :: Compacted ) ; } if compact_index > self . last_index ( ) . unwrap ( ) { unimplemented ! ( " " compact_index self last_index ( ) unwrap ( ) ) } let i = ( compact_index - offset ) as usize ; self . ents . drain ( .. i ) ; Ok ( ( ) ) }
Compact discards all log entries prior to compactIndex.
Compact discards all log entries prior to compactIndex .
&mut self
compact_index
u64