fn truncate(&mut self, upper: SeqNo) -> Result<(), Error> {
        self.ensure_open()?;
        // TODO: Test the edge cases here.
        if upper <= self.seqno.start || upper > self.seqno.end {
            return Err(format!(
                "invalid truncation {:?} for log containing: {:?}",
                upper, self.seqno
            )
            .into());
        }
        self.seqno = upper..self.seqno.end;

        let mut guard = self.dataz.lock()?;
        guard.metadata.seek(SeekFrom::Start(0))?;
        guard.metadata.set_len(0)?;
        guard
            .metadata
            .write_all(&self.seqno.start.0.to_le_bytes())?;
        guard.metadata.sync_all()?;

        Ok(())
    }
/// Logically truncates the log so that future reads ignore writes at sequence numbers
/// less than `upper`.
///
/// TODO: actually reclaim disk space as part of truncating.
Logically truncates the log so that future reads ignore writes at sequence numbers
less than `upper`.

actually reclaim disk space as part of truncating.
Logically truncates the log so that future reads ignore writes at sequence numbers less than ` upper ` . actually reclaim disk space as part of truncating .
fn truncate(&mut self, upper: SeqNo) -> Result<(), Error> {
        self.ensure_open()?;
        // TODO: Test the edge cases here.
        if upper <= self.seqno.start || upper > self.seqno.end {
            return Err(format!(
                "invalid truncation {:?} for log containing: {:?}",
                upper, self.seqno
            )
            .into());
        }
        self.seqno = upper..self.seqno.end;
        let mut guard = self.dataz.lock()?;
        guard.metadata.seek(SeekFrom::Start(0))?;
        guard.metadata.set_len(0)?;
        guard
            .metadata
            .write_all(&self.seqno.start.0.to_le_bytes())?;
        guard.metadata.sync_all()?;
        Ok(())
    }
fn truncate ( & mut self , upper : SeqNo ) -> Result < ( ) , Error > { self . ensure_open ( ) ? ; // TODO: Test the edge cases here. if upper <= self . seqno . start || upper > self . seqno . end { return Err ( format ! ( " " upper self seqno ) . into ( ) ) ; } self . seqno = upper .. self . seqno . end ; let mut guard = self . dataz . lock ( ) ? ; guard . metadata . seek ( SeekFrom :: Start ( 0 ) ) ? ; guard . metadata . set_len ( 0 ) ? ; guard . metadata . write_all ( & self . seqno . start . 0 . to_le_bytes ( ) ) ? ; guard . metadata . sync_all ( ) ? ; Ok ( ( ) ) }
Logically truncates the log so that future reads ignore writes at sequence numbers
less than `upper`.
Logically truncates the log so that future reads ignore writes at sequence numbers less than ` upper ` .
&mut self
upper
SeqNo
&mut self
upper
SeqNo