pub struct FilHeader {
pub checksum: u32,
pub page_number: u32,
pub prev_page: u32,
pub next_page: u32,
pub lsn: u64,
pub page_type: PageType,
pub flush_lsn: u64,
pub space_id: u32,
}Expand description
Parsed FIL header (38 bytes, present at the start of every InnoDB page).
Fields§
§checksum: u32Checksum (or space id in older formats). Bytes 0-3.
page_number: u32Page number within the tablespace. Bytes 4-7.
prev_page: u32Previous page in the doubly-linked list. Bytes 8-11. FIL_NULL (0xFFFFFFFF) if not used.
next_page: u32Next page in the doubly-linked list. Bytes 12-15. FIL_NULL (0xFFFFFFFF) if not used.
lsn: u64LSN of newest modification to this page. Bytes 16-23.
page_type: PageTypePage type. Bytes 24-25.
flush_lsn: u64Flush LSN (only meaningful for page 0 of system tablespace). Bytes 26-33.
space_id: u32Space ID this page belongs to. Bytes 34-37.
Implementations§
Source§impl FilHeader
impl FilHeader
Sourcepub fn parse(data: &[u8]) -> Option<Self>
pub fn parse(data: &[u8]) -> Option<Self>
Parse a FIL header from a byte slice.
The slice must be at least SIZE_FIL_HEAD (38) bytes.
§Examples
use idb::innodb::page::FilHeader;
use idb::innodb::page_types::PageType;
use byteorder::{BigEndian, WriteBytesExt};
use std::io::{Cursor, Write};
// Build a 38-byte FIL header with known values
let mut buf = vec![0u8; 38];
let mut c = Cursor::new(&mut buf);
c.write_u32::<BigEndian>(0xDEADBEEF).unwrap(); // checksum
c.write_u32::<BigEndian>(3).unwrap(); // page number
c.write_u32::<BigEndian>(2).unwrap(); // prev page
c.write_u32::<BigEndian>(4).unwrap(); // next page
c.write_u64::<BigEndian>(5000).unwrap(); // LSN
c.write_u16::<BigEndian>(17855).unwrap(); // page type (INDEX)
c.write_u64::<BigEndian>(4000).unwrap(); // flush LSN
c.write_u32::<BigEndian>(1).unwrap(); // space ID
let header = FilHeader::parse(&buf).unwrap();
assert_eq!(header.checksum, 0xDEADBEEF);
assert_eq!(header.page_number, 3);
assert_eq!(header.prev_page, 2);
assert_eq!(header.next_page, 4);
assert_eq!(header.lsn, 5000);
assert_eq!(header.page_type, PageType::Index);
assert_eq!(header.flush_lsn, 4000);
assert_eq!(header.space_id, 1);Trait Implementations§
Auto Trait Implementations§
impl Freeze for FilHeader
impl RefUnwindSafe for FilHeader
impl Send for FilHeader
impl Sync for FilHeader
impl Unpin for FilHeader
impl UnsafeUnpin for FilHeader
impl UnwindSafe for FilHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more