pub fn term(&self, i: u64) -> Result<u64, RaftLogError> {
        // the valid from range is [index of dummy entry, last index]
        let dummy_index = self.first_index() - 1;
        if i < dummy_index || i > self.last_index() {
            // TODO: return an error instead?
            return Ok(0);
        }
        if let Some(t) = self.unstable.maybe_term(i) {
            return Ok(t);
        }

        self.storage.term(i).or_else(|e| match e {
            StorageError::Compacted | StorageError::Unavailable => Ok(0),
            _ => panic!("unexpected error: {:?}", e),
        })
    }
// Term return the term of the entry in the given index.
Term return the term of the entry in the given index.
Term return the term of the entry in the given index .
pub fn term(&self, i: u64) -> Result<u64, RaftLogError> {
        // the valid from range is [index of dummy entry, last index]
        let dummy_index = self.first_index() - 1;
        if i < dummy_index || i > self.last_index() {
            // TODO: return an error instead?
            return Ok(0);
        }
        if let Some(t) = self.unstable.maybe_term(i) {
            return Ok(t);
        }
        self.storage.term(i).or_else(|e| match e {
            StorageError::Compacted | StorageError::Unavailable => Ok(0),
            _ => panic!("unexpected error: {:?}", e),
        })
    }
pub fn term ( & self , i : u64 ) -> Result < u64 , RaftLogError > { // the valid from range is [index of dummy entry, last index] let dummy_index = self . first_index ( ) - 1 ; if i < dummy_index || i > self . last_index ( ) { // TODO: return an error instead? return Ok ( 0 ) ; } if let Some ( t ) = self . unstable . maybe_term ( i ) { return Ok ( t ) ; } self . storage . term ( i ) . or_else ( | e | match e { StorageError :: Compacted | StorageError :: Unavailable => Ok ( 0 ) , _ => panic ! ( " " e ) , } ) }
Term return the term of the entry in the given index.
Term return the term of the entry in the given index .
&self
i
u64