pub fn write<R: AsMut<[u8]>>(&mut self, entry: &mut R) -> io::Result<()> {
        let end_pos = self.file.seek(SeekFrom::End(0))?;

        let entry = entry.as_mut();

        let hash = {
            let mut hasher = crc32fast::Hasher::new();
            hasher.update(entry);
            &mut hasher.finalize().to_le_bytes()
        };

        let result = self
            .file
            .write_all(&mut (entry.len() as u64).to_le_bytes())
            .and_then(|_| self.file.write_all(entry))
            .and_then(|_| self.file.write_all(hash));

        if result.is_ok() {
            self.len += 1;
        } else {
            // Trim the data written.
            self.file.set_len(end_pos + 1)?;
        }

        result
    }
/// Write the given log entry to the end of the log
Write the given log entry to the end of the log
Write the given log entry to the end of the log
pub fn write<R: AsMut<[u8]>>(&mut self, entry: &mut R) -> io::Result<()> {
        let end_pos = self.file.seek(SeekFrom::End(0))?;
        let entry = entry.as_mut();
        let hash = {
            let mut hasher = crc32fast::Hasher::new();
            hasher.update(entry);
            &mut hasher.finalize().to_le_bytes()
        };
        let result = self
            .file
            .write_all(&mut (entry.len() as u64).to_le_bytes())
            .and_then(|_| self.file.write_all(entry))
            .and_then(|_| self.file.write_all(hash));
        if result.is_ok() {
            self.len += 1;
        } else {
            // Trim the data written.
            self.file.set_len(end_pos + 1)?;
        }
        result
    }
pub fn write < R : AsMut < [ u8 ] > > ( & mut self , entry : & mut R ) -> io :: Result < ( ) > { let end_pos = self . file . seek ( SeekFrom :: End ( 0 ) ) ? ; let entry = entry . as_mut ( ) ; let hash = { let mut hasher = crc32fast :: Hasher :: new ( ) ; hasher . update ( entry ) ; & mut hasher . finalize ( ) . to_le_bytes ( ) } ; let result = self . file . write_all ( & mut ( entry . len ( ) as u64 ) . to_le_bytes ( ) ) . and_then ( | _ | self . file . write_all ( entry ) ) . and_then ( | _ | self . file . write_all ( hash ) ) ; if result . is_ok ( ) { self . len += 1 ; } else { // Trim the data written. self . file . set_len ( end_pos + 1 ) ? ; } result }
Write the given log entry to the end of the log
Write the given log entry to the end of the log
&mut self
entry
&mut R