/// Terminates the writer. Always call after writting all the data. Returns
/// total amount of bytes written.
Terminates the writer. Always call after writting all the data. Returns
total amount of bytes written.
Terminates the writer . Always call after writting all the data . Returns total amount of bytes written .
pub fn finish(&mut self) -> std::io::Result<u64> {
        // Flush leftovers
        for field in Fields::iterator() {
            self.flush(field);
        }
        for task in self.compressor.finish() {
            self.write_data_and_update_meta(&task);
        }
        let meta_start_pos = self.inner.seek(SeekFrom::Current(0))?;
        // Write meta
        let main_meta = serde_json::to_string(&self.file_meta).unwrap();
        let main_meta_bytes = main_meta.as_bytes();
        let crc32 = calc_crc_for_meta_bytes(main_meta_bytes);
        self.inner.write_all(main_meta_bytes)?;
        let total_bytes_written = self.inner.seek(SeekFrom::Current(0))?;
        // Revert back to the beginning of the file
        self.inner.seek(SeekFrom::Start(0)).unwrap();
        let file_meta = FileInfo::new([1, 0], meta_start_pos, crc32);
        let file_meta_bytes = &Into::<Vec<u8>>::into(file_meta)[..];
        self.inner.write_all(file_meta_bytes)?;
        Ok(total_bytes_written)
    }
pub fn finish ( & mut self ) -> std :: io :: Result < u64 > { // Flush leftovers for field in Fields :: iterator ( ) { self . flush ( field ) ; } for task in self . compressor . finish ( ) { self . write_data_and_update_meta ( & task ) ; } let meta_start_pos = self . inner . seek ( SeekFrom :: Current ( 0 ) ) ? ; // Write meta let main_meta = serde_json :: to_string ( & self . file_meta ) . unwrap ( ) ; let main_meta_bytes = main_meta . as_bytes ( ) ; let crc32 = calc_crc_for_meta_bytes ( main_meta_bytes ) ; self . inner . write_all ( main_meta_bytes ) ? ; let total_bytes_written = self . inner . seek ( SeekFrom :: Current ( 0 ) ) ? ; // Revert back to the beginning of the file self . inner . seek ( SeekFrom :: Start ( 0 ) ) . unwrap ( ) ; let file_meta = FileInfo :: new ( [ 1 , 0 ] , meta_start_pos , crc32 ) ; let file_meta_bytes = & Into :: < Vec < u8 > > :: into ( file_meta ) [ .. ] ; self . inner . write_all ( file_meta_bytes ) ? ; Ok ( total_bytes_written ) }
Terminates the writer.
Terminates the writer .
&mut self