fn read_disk_value(&mut self) -> Result<T, super::Error> {
        loop {
            match self.fp.read_u32::<BigEndian>() {
                Ok(payload_size_in_bytes) => {
                    let mut payload_buf = vec![0; payload_size_in_bytes as usize];
                    match self.fp.read_exact(&mut payload_buf[..]) {
                        Ok(()) => {
                            let mut dec = DeflateDecoder::new(&payload_buf[..]);
                            match deserialize_from(&mut dec) {
                                Ok(event) => {
                                    self.disk_writes_to_read -= 1;
                                    return Ok(event);
                                }
                                Err(e) => panic!("Failed decoding. Skipping {:?}", e),
                            }
                        }
                        Err(e) => {
                            panic!(
                                "Error, on-disk payload of advertised size not available! \
                                 Recv failed with error {:?}",
                                e
                            );
                        }
                    }
                }
                Err(e) => {
                    match e.kind() {
                        ErrorKind::UnexpectedEof => {
                            // Okay, we're pretty sure that no one snuck data in
                            // on us. We check the metadata condition of the
                            // file and, if we find it read-only, switch on over
                            // to a new log file.
                            let metadata = self
                                .fp
                                .get_ref()
                                .metadata()
                                .expect("could not get metadata at UnexpectedEof");
                            if metadata.permissions().readonly() {
                                match private::read_seq_num_min(&self.root) {
                                    Ok(seq_num) => {
                                        let old_log = self.root.join(format!("{}", seq_num));
                                        fs::remove_file(old_log).expect("could not remove log");
                                        self.max_disk_files.fetch_add(1, Ordering::Relaxed);
                                        let lg =
                                            self.root.join(format!("{}", seq_num.wrapping_add(1)));
                                        match fs::OpenOptions::new().read(true).open(&lg) {
                                            Ok(fp) => {
                                                self.fp = BufReader::new(fp);
                                                continue;
                                            }
                                            Err(e) => return Err(super::Error::IoError(e)),
                                        }
                                    }
                                    Err(e) => {
                                        return Err(super::Error::IoError(e));
                                    }
                                }
                            }
                        }
                        _ => return Err(super::Error::IoError(e)),
                    }
                }
            }
        }
    }
// This function is _only_ called when there's disk writes to be read. If a
// disk read happens and no `T` is returned this is an unrecoverable error.
This function is _only_ called when there's disk writes to be read. If a
disk read happens and no `T` is returned this is an unrecoverable error.
This function is _only_ called when there ' s disk writes to be read . If a disk read happens and no ` T ` is returned this is an unrecoverable error .
fn read_disk_value(&mut self) -> Result<T, super::Error> {
        loop {
            match self.fp.read_u32::<BigEndian>() {
                Ok(payload_size_in_bytes) => {
                    let mut payload_buf = vec![0; payload_size_in_bytes as usize];
                    match self.fp.read_exact(&mut payload_buf[..]) {
                        Ok(()) => {
                            let mut dec = DeflateDecoder::new(&payload_buf[..]);
                            match deserialize_from(&mut dec) {
                                Ok(event) => {
                                    self.disk_writes_to_read -= 1;
                                    return Ok(event);
                                }
                                Err(e) => panic!("Failed decoding. Skipping {:?}", e),
                            }
                        }
                        Err(e) => {
                            panic!(
                                "Error, on-disk payload of advertised size not available! \
                                 Recv failed with error {:?}",
                                e
                            );
                        }
                    }
                }
                Err(e) => {
                    match e.kind() {
                        ErrorKind::UnexpectedEof => {
                            // Okay, we're pretty sure that no one snuck data in
                            // on us. We check the metadata condition of the
                            // file and, if we find it read-only, switch on over
                            // to a new log file.
                            let metadata = self
                                .fp
                                .get_ref()
                                .metadata()
                                .expect("could not get metadata at UnexpectedEof");
                            if metadata.permissions().readonly() {
                                match private::read_seq_num_min(&self.root) {
                                    Ok(seq_num) => {
                                        let old_log = self.root.join(format!("{}", seq_num));
                                        fs::remove_file(old_log).expect("could not remove log");
                                        self.max_disk_files.fetch_add(1, Ordering::Relaxed);
                                        let lg =
                                            self.root.join(format!("{}", seq_num.wrapping_add(1)));
                                        match fs::OpenOptions::new().read(true).open(&lg) {
                                            Ok(fp) => {
                                                self.fp = BufReader::new(fp);
                                                continue;
                                            }
                                            Err(e) => return Err(super::Error::IoError(e)),
                                        }
                                    }
                                    Err(e) => {
                                        return Err(super::Error::IoError(e));
                                    }
                                }
                            }
                        }
                        _ => return Err(super::Error::IoError(e)),
                    }
                }
            }
        }
    }
fn read_disk_value ( & mut self ) -> Result < T , super :: Error > { loop { match self . fp . read_u32 :: < BigEndian > ( ) { Ok ( payload_size_in_bytes ) => { let mut payload_buf = vec ! [ 0 payload_size_in_bytes as usize ] ; match self . fp . read_exact ( & mut payload_buf [ .. ] ) { Ok ( ( ) ) => { let mut dec = DeflateDecoder :: new ( & payload_buf [ .. ] ) ; match deserialize_from ( & mut dec ) { Ok ( event ) => { self . disk_writes_to_read -= 1 ; return Ok ( event ) ; } Err ( e ) => panic ! ( " " e ) , } } Err ( e ) => { panic ! ( " \
 " e ) ; } } } Err ( e ) => { match e . kind ( ) { ErrorKind :: UnexpectedEof => { // Okay, we're pretty sure that no one snuck data in // on us. We check the metadata condition of the // file and, if we find it read-only, switch on over // to a new log file. let metadata = self . fp . get_ref ( ) . metadata ( ) . expect ( " " ) ; if metadata . permissions ( ) . readonly ( ) { match private :: read_seq_num_min ( & self . root ) { Ok ( seq_num ) => { let old_log = self . root . join ( format ! ( " " seq_num ) ) ; fs :: remove_file ( old_log ) . expect ( " " ) ; self . max_disk_files . fetch_add ( 1 , Ordering :: Relaxed ) ; let lg = self . root . join ( format ! ( " " seq_num wrapping_add ( 1 ) ) ) ; match fs :: OpenOptions :: new ( ) . read ( true ) . open ( & lg ) { Ok ( fp ) => { self . fp = BufReader :: new ( fp ) ; continue ; } Err ( e ) => return Err ( super :: Error :: IoError ( e ) ) , } } Err ( e ) => { return Err ( super :: Error :: IoError ( e ) ) ; } } } } _ => return Err ( super :: Error :: IoError ( e ) ) , } } } } }
This function is _only_ called when there's disk writes to be read.
This function is _only_ called when there ' s disk writes to be read .
&mut self
&mut self