pub fn front_truncate(&mut self, config: &StoreConfig, len: usize) -> Result<()> {
        let metadata = self.file.metadata()?;
        let store_size = metadata.len();
        let len = (len * E::byte_len()) as u64;

        ensure!(store_size >= len, "Invalid truncation length");

        // Seek the reader past the length we want removed.
        let mut reader = OpenOptions::new()
            .read(true)
            .open(StoreConfig::data_path(&config.path, &config.id))?;
        reader.seek(SeekFrom::Start(len))?;

        // Make sure the store file is opened for read/write.
        self.file = OpenOptions::new()
            .read(true)
            .write(true)
            .open(StoreConfig::data_path(&config.path, &config.id))?;

        // Seek the writer.
        self.file.seek(SeekFrom::Start(0))?;

        let written = copy(&mut reader, &mut self.file)?;
        ensure!(written == store_size - len, "Failed to copy all data");

        self.file.set_len(written)?;

        Ok(())
    }
// Remove 'len' elements from the front of the file.
Remove 'len' elements from the front of the file.
Remove ' len ' elements from the front of the file .
pub fn front_truncate(&mut self, config: &StoreConfig, len: usize) -> Result<()> {
        let metadata = self.file.metadata()?;
        let store_size = metadata.len();
        let len = (len * E::byte_len()) as u64;
        ensure!(store_size >= len, "Invalid truncation length");
        // Seek the reader past the length we want removed.
        let mut reader = OpenOptions::new()
            .read(true)
            .open(StoreConfig::data_path(&config.path, &config.id))?;
        reader.seek(SeekFrom::Start(len))?;
        // Make sure the store file is opened for read/write.
        self.file = OpenOptions::new()
            .read(true)
            .write(true)
            .open(StoreConfig::data_path(&config.path, &config.id))?;
        // Seek the writer.
        self.file.seek(SeekFrom::Start(0))?;
        let written = copy(&mut reader, &mut self.file)?;
        ensure!(written == store_size - len, "Failed to copy all data");
        self.file.set_len(written)?;
        Ok(())
    }
pub fn front_truncate ( & mut self , config : & StoreConfig , len : usize ) -> Result < ( ) > { let metadata = self . file . metadata ( ) ? ; let store_size = metadata . len ( ) ; let len = ( len * E :: byte_len ( ) ) as u64 ; ensure ! ( store_size len " " ) ; // Seek the reader past the length we want removed. let mut reader = OpenOptions :: new ( ) . read ( true ) . open ( StoreConfig :: data_path ( & config . path , & config . id ) ) ? ; reader . seek ( SeekFrom :: Start ( len ) ) ? ; // Make sure the store file is opened for read/write. self . file = OpenOptions :: new ( ) . read ( true ) . write ( true ) . open ( StoreConfig :: data_path ( & config . path , & config . id ) ) ? ; // Seek the writer. self . file . seek ( SeekFrom :: Start ( 0 ) ) ? ; let written = copy ( & mut reader , & mut self . file ) ? ; ensure ! ( written store_size len " " ) ; self . file . set_len ( written ) ? ; Ok ( ( ) ) }
Remove 'len' elements from the front of the file.
Remove ' len ' elements from the front of the file .
&mut self
config
&StoreConfig
len
usize