Skip to main content

EseDatabase

Struct EseDatabase 

Source
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: EseHeader

Parsed file header.

Implementations§

Source§

impl EseDatabase

Source

pub fn open(path: &Path) -> Result<Self, EseError>

Open an ESE database at path and memory-map the entire file.

§Errors

Returns EseError if the file cannot be opened, mapped, or is not a valid ESE database.

Source

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.

Source

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.

Source

pub fn page_count(&self) -> u64

Return the total number of pages in the file (including the header page).

Source

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.

Source

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_LEAF set, 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.

Source

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.

Source

pub fn table_records_from_root( &self, root_page: u32, ) -> Result<TableCursor<'_>, EseError>

Open a cursor over all leaf records starting at root_page.

§Errors

Returns EseError if the leaf pages cannot be walked from root_page.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for EseDatabase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.