Library API Overview

The idb crate provides Rust types and functions for parsing InnoDB tablespace files, redo logs, and related binary structures programmatically. It is published as the innodb-utils package on crates.io.

Adding as a Dependency

[dependencies]
idb = { package = "innodb-utils", version = "2" }

For library-only usage (no CLI modules), disable default features:

[dependencies]
idb = { package = "innodb-utils", version = "2", default-features = false }

Feature Flags

FeatureDefaultDescription
cliYesCLI-specific modules (clap, colored, indicatif, etc.). Disable with default-features = false for library-only usage.
mysqlNoLive MySQL queries via mysql_async + tokio. Implies cli.

Key Entry Points

Type / FunctionModulePurpose
Tablespaceidb::innodb::tablespaceOpen .ibd files, read pages, iterate over all pages
FilHeaderidb::innodb::pageParse the 38-byte FIL header from any InnoDB page
FilTraileridb::innodb::pageParse the 8-byte FIL trailer from any InnoDB page
FspHeaderidb::innodb::pageParse the FSP header from page 0 (space ID, size, flags)
PageTypeidb::innodb::page_typesMap page type codes to names, descriptions, and usage notes
validate_checksumidb::innodb::checksumCRC-32C, legacy InnoDB, and MariaDB full_crc32 validation
validate_lsnidb::innodb::checksumLSN consistency check between header and trailer
find_sdi_pagesidb::innodb::sdiLocate SDI pages in a tablespace
extract_sdi_from_pagesidb::innodb::sdiExtract and decompress SDI metadata records
LogFileidb::innodb::logOpen and parse redo log files
VendorInfoidb::innodb::vendorVendor detection (MySQL, Percona, MariaDB)

Module Overview

The library is organized under idb::innodb:

ModulePurpose
tablespaceFile I/O abstraction, page size auto-detection, page iteration
pageFIL header (38 bytes), FIL trailer (8 bytes), FSP header parsing
page_typesPage type enum mapping u16 codes to names and descriptions
checksumCRC-32C and legacy InnoDB checksum validation
indexINDEX page internals -- B+Tree header, FSEG, system records
recordRow-level record parsing -- compact format, variable-length fields
sdiSDI metadata extraction from MySQL 8.0+ tablespaces
logRedo log file header, checkpoints, and data block parsing
undoUNDO log page header and segment header parsing
lobLarge object page headers (old-style BLOB and MySQL 8.0+ LOB)
compressionCompression algorithm detection and decompression (zlib, LZ4)
encryptionEncryption detection from FSP flags, encryption info parsing
keyringMySQL keyring_file plugin format reader
decryptionAES-256-CBC page decryption using tablespace keys
vendorVendor detection (MySQL, Percona, MariaDB) and format variants
constantsInnoDB page/file structure constants from MySQL source headers

Quick Example

use idb::innodb::tablespace::Tablespace;
use idb::innodb::page::FilHeader;
use idb::innodb::checksum::validate_checksum;

let mut ts = Tablespace::open("employees.ibd").unwrap();
println!("Page size: {} bytes", ts.page_size());
println!("Total pages: {}", ts.page_count());
println!("Vendor: {}", ts.vendor_info());

// Read and inspect page 0
let page = ts.read_page(0).unwrap();
let header = FilHeader::parse(&page).unwrap();
println!("Page type: {}", header.page_type);

// Validate checksum
let result = validate_checksum(&page, ts.page_size(), Some(ts.vendor_info()));
println!("Checksum valid: {}", result.valid);

API Reference

Full API documentation is available on docs.rs: https://docs.rs/innodb-utils