Try to extract the commit header from the asked position without advancing seek. `IndexFileMut` fsync asynchoronously, which makes it important for reader to verify its entry
(
mut reader: &mut Reader,
byte_offset: u64,
)
| 514 | /// Try to extract the commit header from the asked position without advancing seek. |
| 515 | /// `IndexFileMut` fsync asynchoronously, which makes it important for reader to verify its entry |
| 516 | pub fn validate_commit_header<Reader: io::Read + io::Seek>( |
| 517 | mut reader: &mut Reader, |
| 518 | byte_offset: u64, |
| 519 | ) -> io::Result<commit::Header> { |
| 520 | let pos = reader.stream_position()?; |
| 521 | reader.seek(SeekFrom::Start(byte_offset))?; |
| 522 | |
| 523 | let hdr = commit::Header::decode(&mut reader) |
| 524 | .and_then(|hdr| hdr.ok_or_else(|| io::Error::new(ErrorKind::UnexpectedEof, "unexpected EOF"))); |
| 525 | |
| 526 | // Restore the original position |
| 527 | reader.seek(SeekFrom::Start(pos))?; |
| 528 | |
| 529 | hdr |
| 530 | } |
| 531 | |
| 532 | /// Pair of transaction offset and payload. |
| 533 | /// |
no test coverage detected
searching dependent graphs…