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
TypeDefindexes 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: u32Row 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: TokenMetadata 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: usizeByte 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: u32Raw 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: u32Raw 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
impl NestedClassRaw
pub fn apply(
classes: &MetadataTable<'_, NestedClassRaw>,
types: &TypeRegistry,
) -> Result<()>
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 allNestedClassentriestypes- 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>
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
impl Clone for NestedClassRaw
§fn clone(&self) -> NestedClassRaw
fn clone(&self) -> NestedClassRaw
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for NestedClassRaw
impl Debug for NestedClassRaw
§impl RowReadable for NestedClassRaw
impl RowReadable for NestedClassRaw
§fn row_read(
data: &[u8],
offset: &mut usize,
rid: u32,
sizes: &TableInfoRef,
) -> Result<Self>
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:
NestedClass(2-4 bytes): Index intoTypeDeftable for nested typeEnclosingClass(2-4 bytes): Index intoTypeDeftable for enclosing type
§Arguments
data- Binary data containing the tableoffset- Current read position (updated by this method)rid- Row identifier for this entrysizes- 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
TypeDefindex values
§impl RowWritable for NestedClassRaw
impl RowWritable for NestedClassRaw
§fn row_write(
&self,
data: &mut [u8],
offset: &mut usize,
_rid: u32,
sizes: &TableInfoRef,
) -> Result<()>
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 dataoffset- 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
impl TableRow for NestedClassRaw
§fn row_size(sizes: &TableInfoRef) -> u32
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 intoTypeDeftable)enclosing_class: 2 or 4 bytes (table index intoTypeDeftable)
Total: 4-8 bytes depending on table index size configuration
Auto Trait Implementations§
impl Freeze for NestedClassRaw
impl RefUnwindSafe for NestedClassRaw
impl Send for NestedClassRaw
impl Sync for NestedClassRaw
impl Unpin for NestedClassRaw
impl UnwindSafe for NestedClassRaw
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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