pub struct EseDatabase {
pub header: EseHeader,
/* private fields */
}Expand description
An open ESE database file, memory-mapped for zero-copy page access.
The file is mapped once at open time. All subsequent
read_page and raw_page_slice
calls slice directly into the mapping — no additional syscalls or heap
allocations per page.
§Safety invariant
The mapping is read-only. Callers must not modify the file on disk while an
EseDatabase is live; doing so is undefined behaviour (per memmap2 docs).
In practice SRUDB.dat is treated as forensic evidence and never written.
Fields§
§header: EseHeaderParsed file header.
Implementations§
Source§impl EseDatabase
impl EseDatabase
Sourcepub fn raw_page_slice(&self, page_number: u32) -> Result<&[u8], EseError>
pub fn raw_page_slice(&self, page_number: u32) -> Result<&[u8], EseError>
Return a zero-copy slice of the raw bytes for page page_number.
The slice borrows directly from the memory mapping — no heap allocation.
Returns EseError::Corrupt if page_number is beyond the end of the
file.
§Errors
Returns EseError if the requested page is out of range.
Sourcepub fn read_page(&self, page_number: u32) -> Result<EsePage, EseError>
pub fn read_page(&self, page_number: u32) -> Result<EsePage, EseError>
Read a single page by its 0-based page number.
Page 0 is the header page. Data pages start at page 1.
Returns EseError::Corrupt if page_number is beyond the file.
§Errors
Returns EseError on I/O error or if the page is out of range.
Sourcepub fn page_count(&self) -> u64
pub fn page_count(&self) -> u64
Return the total number of pages in the file (including the header page).
Sourcepub fn catalog_entries(&self) -> Result<Vec<CatalogEntry>, EseError>
pub fn catalog_entries(&self) -> Result<Vec<CatalogEntry>, EseError>
Read and parse all entries from the ESE catalog (physical page 5).
The catalog (MSysObjects) maps table names to their root B-tree page numbers. Physical page 5 is the catalog root in real SRUDB.dat files (fdp=2, ROOT|PARENT or ROOT|LEAF).
Each tag on the catalog leaf pages (tags 1+, skipping tag 0) is first
tried against the real ESE tagged-column format via
CatalogEntry::parse_real_catalog_record, then against the synthetic
fixture format via CatalogEntry::from_bytes as a fallback.
§Errors
Returns EseError if the catalog page cannot be read or contains
malformed records.
Sourcepub fn walk_leaf_pages(&self, root_page: u32) -> Result<Vec<u32>, EseError>
pub fn walk_leaf_pages(&self, root_page: u32) -> Result<Vec<u32>, EseError>
Walk the B-tree rooted at root_page and return the page numbers of
all leaf pages.
- If the page has
PAGE_FLAG_LEAFset, it is returned directly. - Otherwise each tag (skipping tag 0) is treated as a parent-node
reference: the child page ESE number is stored in the last 4 bytes
of the tag data (after any B-tree key prefix). The physical page is
stored_value + 1(ESE uses 0-based data-page numbering, offset by the file-header page).
§Errors
Returns EseError if any page cannot be read or parsed.
Sourcepub fn find_table_page(&self, name: &str) -> Result<u32, EseError>
pub fn find_table_page(&self, name: &str) -> Result<u32, EseError>
Find the root B-tree page number for the named table.
Reads the catalog and returns the table_page of the first entry
whose object_name matches name.
§Errors
Returns EseError::TableNotFound if no matching table is in the catalog,
or any I/O / parse error from catalog_entries.
Sourcepub fn table_records_from_root(
&self,
root_page: u32,
) -> Result<TableCursor<'_>, EseError>
pub fn table_records_from_root( &self, root_page: u32, ) -> Result<TableCursor<'_>, EseError>
Sourcepub fn table_columns(
&self,
table_name: &str,
) -> Result<Vec<ColumnDef>, EseError>
pub fn table_columns( &self, table_name: &str, ) -> Result<Vec<ColumnDef>, EseError>
Return the column definitions for a named table from the catalog.
Reads the catalog, finds the table entry (object_type 1) whose name
matches table_name, then collects all column entries (object_type 2)
whose parent_object_id equals the table’s object_id. In the
synthetic catalog format, column entries store the JET coltyp in the
table_page field. Results are sorted ascending by column_id.
§Errors
Returns EseError::TableNotFound if table_name is not in the
catalog, or any I/O / parse error from catalog_entries.
Sourcepub fn table_records(
&self,
table_name: &str,
) -> Result<TableCursor<'_>, EseError>
pub fn table_records( &self, table_name: &str, ) -> Result<TableCursor<'_>, EseError>
Open a cursor over all records in a named SRUM table.
Returns Err(EseError::TableNotFound) immediately if the table is absent.
§Errors
Returns EseError::TableNotFound if table_name is not in the catalog,
or any I/O / parse error from reading the catalog or walking leaf pages.