Struct NestedClassRaw

pub struct NestedClassRaw {
    pub rid: u32,
    pub token: Token,
    pub offset: usize,
    pub nested_class: u32,
    pub enclosing_class: u32,
}
Expand description

Raw representation of a NestedClass table entry with unresolved indexes.

This structure represents the unprocessed entry from the NestedClass metadata table (ID 0x29), which defines the hierarchical relationship between nested types and their enclosing types. It contains raw index values that require resolution to actual type objects.

§Purpose

The NestedClass table establishes type containment relationships:

  • Defines which types are nested within other types
  • Establishes type visibility and accessibility scoping
  • Enables proper type resolution within nested contexts
  • Supports complex type hierarchies and namespace organization

§Raw vs Owned

This raw variant is used during initial metadata parsing and contains:

  • Unresolved TypeDef indexes requiring lookup in the type registry
  • Minimal memory footprint for storage
  • Direct representation of file format

Use NestedClass for resolved references and runtime access.

§Type Relationships

NestedClass entries create hierarchical type relationships:

  • Containment: The nested type is contained within the enclosing type
  • Scoping: Nested types inherit accessibility from their container
  • Resolution: Type names are resolved relative to the enclosing context
  • Compilation: Nested types share compilation context with their container

§ECMA-335 Reference

Corresponds to ECMA-335 §II.22.32 NestedClass table structure.

Fields§

§rid: u32

Row identifier within the NestedClass table.

Unique identifier for this NestedClass entry within the table. Combined with table ID 0x29, forms the metadata token 0x29FFFFFF.

§token: Token

Metadata token for this NestedClass entry.

Token in the format 0x29FFFFFF, where the high byte 0x29 identifies the NestedClass table and the low 3 bytes contain the row ID.

§offset: usize

Byte offset of this entry in the original metadata stream.

Points to the start of this entry’s data in the metadata file. Used for debugging and low-level metadata inspection.

§nested_class: u32

Raw index into the TypeDef table for the nested type.

This unresolved index identifies the type that is nested within the enclosing type. Must be resolved using the type registry to get the actual type object. Index size depends on TypeDef table size.

§enclosing_class: u32

Raw index into the TypeDef table for the enclosing type.

This unresolved index identifies the type that contains the nested type. Must be resolved using the type registry to get the actual type object. Index size depends on TypeDef table size.

Implementations§

§

impl NestedClassRaw

pub fn apply( classes: &MetadataTable<'_, NestedClassRaw>, types: &TypeRegistry, ) -> Result<()>

Applies all NestedClass entries to establish type containment relationships.

This static method processes all NestedClass entries from the metadata table, validating the relationships and updating the type registry to reflect the nested type hierarchy. The operation groups nested types by their enclosing types for efficient processing.

§Arguments
  • classes - The metadata table containing all NestedClass entries
  • types - The type registry containing all parsed type entries
§Returns

Returns Ok(()) if all relationships are successfully applied.

§Errors
  • Nested class validation fails (circular nesting, same type, etc.)
  • Referenced types cannot be found in the type registry
  • Type tokens are invalid or malformed
  • The relationship violates .NET type system constraints

pub fn to_owned(&self, types: &TypeRegistry) -> Result<NestedClassRc>

Converts this raw entry to an owned NestedClass with resolved references.

This method resolves the raw TypeDef indexes to actual type objects, creating a fully usable NestedClass instance for runtime access. The conversion establishes the containment relationship between nested and enclosing types.

§Arguments
  • types - The type registry containing all parsed type entries
§Returns

A reference-counted NestedClassRc containing the resolved nesting relationship.

§Errors
  • The nested class type cannot be resolved in the type registry
  • The enclosing class type cannot be resolved in the type registry
  • Type tokens are invalid or malformed
  • Referenced types are corrupted or incomplete

Trait Implementations§

§

impl Clone for NestedClassRaw

§

fn clone(&self) -> NestedClassRaw

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for NestedClassRaw

§

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

Formats the value using the given formatter. Read more
§

impl RowReadable for NestedClassRaw

§

fn row_read( data: &[u8], offset: &mut usize, rid: u32, sizes: &TableInfoRef, ) -> Result<Self>

Reads a single NestedClass table row from binary data.

Parses the binary representation according to ECMA-335 §II.22.32:

  1. NestedClass (2-4 bytes): Index into TypeDef table for nested type
  2. EnclosingClass (2-4 bytes): Index into TypeDef table for enclosing type
§Arguments
  • data - Binary data containing the table
  • offset - Current read position (updated by this method)
  • rid - Row identifier for this entry
  • sizes - Table size information for proper index width calculation
§Returns

Parsed NestedClassRaw instance with populated fields

§Errors
  • Insufficient data remaining at offset
  • Data corruption or malformed structure
  • Invalid TypeDef index values
§

impl RowWritable for NestedClassRaw

§

fn row_write( &self, data: &mut [u8], offset: &mut usize, _rid: u32, sizes: &TableInfoRef, ) -> Result<()>

Serialize a NestedClass table row to binary format

Writes the row data according to ECMA-335 §II.22.32 specification:

  • nested_class: TypeDef table index (type that is nested)
  • enclosing_class: TypeDef table index (type that contains the nested type)
§Arguments
  • data - Target buffer for writing binary data
  • offset - Current write position (updated after write)
  • rid - Row identifier (unused in this implementation)
  • sizes - Table sizing information for index widths
§Returns

Ok(()) on successful write, error on buffer overflow or encoding failure

§

impl TableRow for NestedClassRaw

§

fn row_size(sizes: &TableInfoRef) -> u32

Calculate the row size for NestedClass table entries

Returns the total byte size of a single NestedClass table row based on the table configuration. The size varies depending on the size of table indexes in the metadata.

§Size Breakdown
  • nested_class: 2 or 4 bytes (table index into TypeDef table)
  • enclosing_class: 2 or 4 bytes (table index into TypeDef table)

Total: 4-8 bytes depending on table index size configuration

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.