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
'a- Lifetime of the underlying byte dataT- The row type that implementscrate::metadata::tables::types::RowReadable
§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: u32Total number of rows in this table
row_size: u32Size in bytes of each row
sizes: TableInfoRefTable configuration and size information
Implementations§
§impl<'a, T: RowReadable> MetadataTable<'a, T>
impl<'a, T: RowReadable> MetadataTable<'a, T>
pub fn new(data: &'a [u8], row_count: u32, sizes: TableInfoRef) -> Result<Self>
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 datarow_count- The total number of rows present in the tablesizes- 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
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>
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 androw_countinclusive)
§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> ⓘ
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>
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>
impl<'a, T: RowReadable> IntoIterator for &'a MetadataTable<'a, T>
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>
impl<'a, T> Sync for MetadataTable<'a, T>
impl<'a, T> Unpin for MetadataTable<'a, T>
impl<'a, T> UnwindSafe for MetadataTable<'a, T>where
T: RefUnwindSafe,
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
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>
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>
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