Struct MetadataTable

pub struct MetadataTable<'a, T> {
    pub data: &'a [u8],
    pub row_count: u32,
    pub row_size: u32,
    pub sizes: TableInfoRef,
    /* private fields */
}
Expand description

Generic container for metadata table data with typed row access.

This structure provides a high-level interface for working with .NET metadata tables, offering both sequential and parallel iteration capabilities. It wraps raw table data and provides type-safe access to individual rows through the crate::metadata::tables::types::RowReadable trait.

§Type Parameters

§Examples

§Basic Usage

let table: MetadataTable<MyRow> = MetadataTable::new(data, 100, table_info)?;

// Access specific rows
if let Some(first_row) = table.get(1) {
    println!("First row ID: {}", first_row.id);
}

// Sequential iteration
for (index, row) in table.iter().enumerate() {
    println!("Row {}: ID = {}", index + 1, row.id);
}

§Parallel Processing

let table: MetadataTable<MyRow> = MetadataTable::new(data, 100, table_info)?;

// Parallel processing with automatic error handling
table.par_iter().try_for_each(|row| {
    // Process each row in parallel
    println!("Processing row: {}", row.id);
    Ok(())
})?;

Fields§

§data: &'a [u8]

Reference to the raw table data bytes

§row_count: u32

Total number of rows in this table

§row_size: u32

Size in bytes of each row

§sizes: TableInfoRef

Table configuration and size information

Implementations§

§

impl<'a, T: RowReadable> MetadataTable<'a, T>

pub fn new(data: &'a [u8], row_count: u32, sizes: TableInfoRef) -> Result<Self>

Creates a new metadata table from raw byte data.

This constructor initializes a new table wrapper around the provided byte data, calculating the appropriate row size based on the table configuration and setting up the necessary metadata for efficient access operations.

§Arguments
  • data - The raw byte buffer containing the table data
  • row_count - The total number of rows present in the table
  • sizes - Table configuration containing heap sizes and other metadata required for proper row size calculation
§Returns

Returns a Result containing the new MetadataTable instance on success.

§Errors

Returns an error if:

  • The provided data buffer is too small for the specified row count
  • The table configuration is invalid or inconsistent
  • Row size calculation fails due to invalid size parameters

pub fn size(&self) -> u64

Returns the total size of this table in bytes.

Calculates the total memory footprint of the table by multiplying the number of rows by the size of each row.

§Returns

The total size in bytes as a u64 to accommodate large tables.

pub fn get(&self, index: u32) -> Option<T>

Retrieves a specific row by its 1-based index.

This method provides direct access to individual table rows using the CLI specification’s 1-based indexing scheme. Row 0 is reserved and represents a null reference in the metadata format.

§Arguments
  • index - The 1-based row index to retrieve (must be between 1 and row_count inclusive)
§Returns

Returns Some(T) if the row exists and can be parsed successfully, or None if the index is out of bounds or parsing fails.

pub fn iter(&'a self) -> TableIterator<'a, T>

Creates a sequential iterator over all rows in the table.

This method returns an iterator that will process each row in the table sequentially, parsing rows on-demand as the iterator advances. The iterator follows standard Rust iterator conventions and can be used with iterator combinators and for-loops.

§Returns

A TableIterator that yields each row in sequence.

pub fn par_iter(&'a self) -> TableParIterator<'a, T>

Creates a parallel iterator over all rows in the table.

This method returns a parallel iterator that can process rows concurrently across multiple threads, providing significant performance improvements for large tables. The iterator integrates with the Rayon parallel processing framework and supports all standard parallel iterator operations.

§Returns

A TableParIterator that can process rows in parallel.

Trait Implementations§

§

impl<'a, T: RowReadable> IntoIterator for &'a MetadataTable<'a, T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = TableIterator<'a, T>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for MetadataTable<'a, T>

§

impl<'a, T> RefUnwindSafe for MetadataTable<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for MetadataTable<'a, T>
where T: Sync + Send,

§

impl<'a, T> Sync for MetadataTable<'a, T>
where T: Sync + Send,

§

impl<'a, T> Unpin for MetadataTable<'a, T>

§

impl<'a, T> UnwindSafe for MetadataTable<'a, T>
where T: RefUnwindSafe,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.