/// Applies this delta to the specified file.
/// Precondition: `file` is seekable and writeable.
Applies this delta to the specified file.
Precondition: `file` is seekable and writeable.
Applies this delta to the specified file . Precondition : ` file ` is seekable and writeable .
fn apply_to_file(&self, file: &mut File, path: &Path) -> Result<(), PersistenceError> {
        use std::io::{Seek, SeekFrom};
        for (index, page) in self.iter() {
            let offset = index.get() * PAGE_SIZE as u64;
            file.seek(SeekFrom::Start(offset as u64)).map_err(|err| {
                PersistenceError::FileSystemError {
                    path: path.display().to_string(),
                    context: format!("Failed to seek to {}", offset),
                    internal_error: err.to_string(),
                }
            })?;
            let mut contents = page.contents() as &[u8];
            std::io::copy(&mut contents, file).map_err(|err| {
                PersistenceError::FileSystemError {
                    path: path.display().to_string(),
                    context: format!("Failed to copy page #{}", index),
                    internal_error: err.to_string(),
                }
            })?;
        }
        Ok(())
    }
fn apply_to_file ( & self , file : & mut File , path : & Path ) -> Result < ( ) , PersistenceError > { use std :: io :: { Seek , SeekFrom } ; for ( index , page ) in self . iter ( ) { let offset = index . get ( ) * PAGE_SIZE as u64 ; file . seek ( SeekFrom :: Start ( offset as u64 ) ) . map_err ( | err | { PersistenceError :: FileSystemError { path : path . display ( ) . to_string ( ) , context : format ! ( " " offset ) , internal_error : err . to_string ( ) , } } ) ? ; let mut contents = page . contents ( ) as & [ u8 ] ; std :: io :: copy ( & mut contents , file ) . map_err ( | err | { PersistenceError :: FileSystemError { path : path . display ( ) . to_string ( ) , context : format ! ( " " index ) , internal_error : err . to_string ( ) , } } ) ? ; } Ok ( ( ) ) }
Applies this delta to the specified file.
Applies this delta to the specified file .
&self
file
&mut File
path
&Path