pub fn create_snapshot<T>(
        &mut self,
        i: u64,
        cs: T,
        data: Bytes,
    ) -> Result<Snapshot, StorageError>
    where
        T: Into<Option<ConfState>>,
    {
        if i <= self.snapshot.get_metadata().get_index() {
            return Err(StorageError::SnapshotOfDate);
        }
        let offset = self.ents.first().unwrap().get_Index();
        if i > self.last_index().unwrap() {
            unimplemented!(
                "snapshot {} is out of bound last_index({})",
                i,
                self.last_index().unwrap()
            );
        }
        self.snapshot.mut_metadata().set_index(i);
        self.snapshot
            .mut_metadata()
            .set_term(self.ents[(i - offset) as usize].get_Term());
        let cs = cs.into();
        if cs.is_some() {
            // TODO: what is it
            self.snapshot.mut_metadata().set_conf_state(cs.unwrap());
        }
        self.snapshot.set_data(data);
        Ok(self.snapshot.clone())
    }
// create_snapshot makes a snapshot which can be retrieved with Snapshot() and
// can be used to reconstruct the state at that point.
// If any configuration changes have been made since the last compaction,
// the result of the last ApplyConfigChange must be passed in.
create_snapshot makes a snapshot which can be retrieved with Snapshot() and
can be used to reconstruct the state at that point.
If any configuration changes have been made since the last compaction,
the result of the last ApplyConfigChange must be passed in.
create_snapshot makes a snapshot which can be retrieved with Snapshot () and can be used to reconstruct the state at that point . If any configuration changes have been made since the last compaction the result of the last ApplyConfigChange must be passed in .
pub fn create_snapshot<T>(
        &mut self,
        i: u64,
        cs: T,
        data: Bytes,
    ) -> Result<Snapshot, StorageError>
    where
        T: Into<Option<ConfState>>,
    {
        if i <= self.snapshot.get_metadata().get_index() {
            return Err(StorageError::SnapshotOfDate);
        }
        let offset = self.ents.first().unwrap().get_Index();
        if i > self.last_index().unwrap() {
            unimplemented!(
                "snapshot {} is out of bound last_index({})",
                i,
                self.last_index().unwrap()
            );
        }
        self.snapshot.mut_metadata().set_index(i);
        self.snapshot
            .mut_metadata()
            .set_term(self.ents[(i - offset) as usize].get_Term());
        let cs = cs.into();
        if cs.is_some() {
            // TODO: what is it
            self.snapshot.mut_metadata().set_conf_state(cs.unwrap());
        }
        self.snapshot.set_data(data);
        Ok(self.snapshot.clone())
    }
pub fn create_snapshot < T > ( & mut self , i : u64 , cs : T , data : Bytes , ) -> Result < Snapshot , StorageError > where T : Into < Option < ConfState > > , { if i <= self . snapshot . get_metadata ( ) . get_index ( ) { return Err ( StorageError :: SnapshotOfDate ) ; } let offset = self . ents . first ( ) . unwrap ( ) . get_Index ( ) ; if i > self . last_index ( ) . unwrap ( ) { unimplemented ! ( " " i self last_index ( ) unwrap ( ) ) ; } self . snapshot . mut_metadata ( ) . set_index ( i ) ; self . snapshot . mut_metadata ( ) . set_term ( self . ents [ ( i - offset ) as usize ] . get_Term ( ) ) ; let cs = cs . into ( ) ; if cs . is_some ( ) { // TODO: what is it self . snapshot . mut_metadata ( ) . set_conf_state ( cs . unwrap ( ) ) ; } self . snapshot . set_data ( data ) ; Ok ( self . snapshot . clone ( ) ) }
create_snapshot makes a snapshot which can be retrieved with Snapshot() and
can be used to reconstruct the state at that point.
create_snapshot makes a snapshot which can be retrieved with Snapshot () and can be used to reconstruct the state at that point .
&mut self
i
u64
cs
T
data
Bytes