pub struct Metadata {Show 51 fields
pub root: MetadataRoot,
pub strings: StringsHeap,
pub user_strings: UserStringsHeap,
pub guids: GuidHeap,
pub blobs: BlobHeap,
pub tables_header: TablesHeader,
pub modules: Vec<ModuleRow>,
pub type_refs: Vec<TypeRefRow>,
pub type_defs: Vec<TypeDefRow>,
pub field_ptrs: Vec<FieldPtrRow>,
pub fields: Vec<FieldRow>,
pub method_ptrs: Vec<MethodPtrRow>,
pub method_defs: Vec<MethodDefRow>,
pub param_ptrs: Vec<ParamPtrRow>,
pub params: Vec<ParamRow>,
pub interface_impls: Vec<InterfaceImplRow>,
pub member_refs: Vec<MemberRefRow>,
pub constants: Vec<ConstantRow>,
pub custom_attributes: Vec<CustomAttributeRow>,
pub field_marshals: Vec<FieldMarshalRow>,
pub decl_securities: Vec<DeclSecurityRow>,
pub class_layouts: Vec<ClassLayoutRow>,
pub field_layouts: Vec<FieldLayoutRow>,
pub stand_alone_sigs: Vec<StandAloneSigRow>,
pub event_maps: Vec<EventMapRow>,
pub event_ptrs: Vec<EventPtrRow>,
pub events: Vec<EventRow>,
pub property_maps: Vec<PropertyMapRow>,
pub property_ptrs: Vec<PropertyPtrRow>,
pub properties: Vec<PropertyRow>,
pub method_semantics: Vec<MethodSemanticsRow>,
pub method_impls: Vec<MethodImplRow>,
pub module_refs: Vec<ModuleRefRow>,
pub type_specs: Vec<TypeSpecRow>,
pub impl_maps: Vec<ImplMapRow>,
pub field_rvas: Vec<FieldRvaRow>,
pub enc_logs: Vec<EncLogRow>,
pub enc_maps: Vec<EncMapRow>,
pub assemblies: Vec<AssemblyRow>,
pub assembly_processors: Vec<AssemblyProcessorRow>,
pub assembly_oses: Vec<AssemblyOsRow>,
pub assembly_refs: Vec<AssemblyRefRow>,
pub assembly_ref_processors: Vec<AssemblyRefProcessorRow>,
pub assembly_ref_oses: Vec<AssemblyRefOsRow>,
pub files: Vec<FileRow>,
pub exported_types: Vec<ExportedTypeRow>,
pub manifest_resources: Vec<ManifestResourceRow>,
pub nested_classes: Vec<NestedClassRow>,
pub generic_params: Vec<GenericParamRow>,
pub method_specs: Vec<MethodSpecRow>,
pub generic_param_constraints: Vec<GenericParamConstraintRow>,
}Expand description
Parsed CLR metadata with read/write support.
Fields§
§root: MetadataRootThe metadata root (BSJB header).
strings: StringsHeapThe #Strings heap.
user_strings: UserStringsHeapThe #US (user strings) heap.
guids: GuidHeapThe #GUID heap.
blobs: BlobHeapThe #Blob heap.
tables_header: TablesHeaderThe tables header.
modules: Vec<ModuleRow>Module table rows (0x00).
type_refs: Vec<TypeRefRow>TypeRef table rows (0x01).
type_defs: Vec<TypeDefRow>TypeDef table rows (0x02).
field_ptrs: Vec<FieldPtrRow>FieldPtr table rows (0x03) - only in uncompressed #- streams.
fields: Vec<FieldRow>Field table rows (0x04).
method_ptrs: Vec<MethodPtrRow>MethodPtr table rows (0x05) - only in uncompressed #- streams.
method_defs: Vec<MethodDefRow>MethodDef table rows (0x06).
param_ptrs: Vec<ParamPtrRow>ParamPtr table rows (0x07) - only in uncompressed #- streams.
params: Vec<ParamRow>Param table rows (0x08).
interface_impls: Vec<InterfaceImplRow>InterfaceImpl table rows (0x09).
member_refs: Vec<MemberRefRow>MemberRef table rows (0x0A).
constants: Vec<ConstantRow>Constant table rows (0x0B).
custom_attributes: Vec<CustomAttributeRow>CustomAttribute table rows (0x0C).
field_marshals: Vec<FieldMarshalRow>FieldMarshal table rows (0x0D).
decl_securities: Vec<DeclSecurityRow>DeclSecurity table rows (0x0E).
class_layouts: Vec<ClassLayoutRow>ClassLayout table rows (0x0F).
field_layouts: Vec<FieldLayoutRow>FieldLayout table rows (0x10).
stand_alone_sigs: Vec<StandAloneSigRow>StandAloneSig table rows (0x11).
event_maps: Vec<EventMapRow>EventMap table rows (0x12).
event_ptrs: Vec<EventPtrRow>EventPtr table rows (0x13) - only in uncompressed #- streams.
events: Vec<EventRow>Event table rows (0x14).
property_maps: Vec<PropertyMapRow>PropertyMap table rows (0x15).
property_ptrs: Vec<PropertyPtrRow>PropertyPtr table rows (0x16) - only in uncompressed #- streams.
properties: Vec<PropertyRow>Property table rows (0x17).
method_semantics: Vec<MethodSemanticsRow>MethodSemantics table rows (0x18).
method_impls: Vec<MethodImplRow>MethodImpl table rows (0x19).
module_refs: Vec<ModuleRefRow>ModuleRef table rows (0x1A).
type_specs: Vec<TypeSpecRow>TypeSpec table rows (0x1B).
impl_maps: Vec<ImplMapRow>ImplMap table rows (0x1C).
field_rvas: Vec<FieldRvaRow>FieldRva table rows (0x1D).
enc_logs: Vec<EncLogRow>EncLog table rows (0x1E) - Edit-and-Continue log.
enc_maps: Vec<EncMapRow>EncMap table rows (0x1F) - Edit-and-Continue mapping.
assemblies: Vec<AssemblyRow>Assembly table rows (0x20, usually 0 or 1).
assembly_processors: Vec<AssemblyProcessorRow>AssemblyProcessor table rows (0x21) - deprecated.
assembly_oses: Vec<AssemblyOsRow>AssemblyOs table rows (0x22) - deprecated.
assembly_refs: Vec<AssemblyRefRow>AssemblyRef table rows (0x23).
assembly_ref_processors: Vec<AssemblyRefProcessorRow>AssemblyRefProcessor table rows (0x24) - deprecated.
assembly_ref_oses: Vec<AssemblyRefOsRow>AssemblyRefOs table rows (0x25) - deprecated.
files: Vec<FileRow>File table rows (0x26) - multi-file assemblies.
exported_types: Vec<ExportedTypeRow>ExportedType table rows (0x27) - type forwarders.
manifest_resources: Vec<ManifestResourceRow>ManifestResource table rows (0x28).
nested_classes: Vec<NestedClassRow>NestedClass table rows (0x29).
generic_params: Vec<GenericParamRow>GenericParam table rows (0x2A).
method_specs: Vec<MethodSpecRow>MethodSpec table rows (0x2B).
generic_param_constraints: Vec<GenericParamConstraintRow>GenericParamConstraint table rows (0x2C).
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn assembly(&self) -> Option<AssemblyInfo>
pub fn assembly(&self) -> Option<AssemblyInfo>
Get assembly information if this is an assembly (not a netmodule).
Sourcepub fn methods(&self) -> Vec<MethodInfo>
pub fn methods(&self) -> Vec<MethodInfo>
Get all method definitions.
Sourcepub fn assembly_refs(&self) -> Vec<AssemblyRefInfo>
pub fn assembly_refs(&self) -> Vec<AssemblyRefInfo>
Get all assembly references.
Sourcepub fn get_type_def(&self, index: u32) -> Option<&TypeDefRow>
pub fn get_type_def(&self, index: u32) -> Option<&TypeDefRow>
Get the TypeDef row at the given 1-based index.
Sourcepub fn get_type_ref(&self, index: u32) -> Option<&TypeRefRow>
pub fn get_type_ref(&self, index: u32) -> Option<&TypeRefRow>
Get the TypeRef row at the given 1-based index.
Sourcepub fn get_type_spec(&self, index: u32) -> Option<&TypeSpecRow>
pub fn get_type_spec(&self, index: u32) -> Option<&TypeSpecRow>
Get the TypeSpec row at the given 1-based index.
Sourcepub fn resolve_type(&self, coded_index: &CodedIndex) -> Option<ResolvedType>
pub fn resolve_type(&self, coded_index: &CodedIndex) -> Option<ResolvedType>
Resolve a TypeDefOrRef coded index to a type reference.
Sourcepub fn get_base_type(&self, type_def_index: u32) -> Option<ResolvedType>
pub fn get_base_type(&self, type_def_index: u32) -> Option<ResolvedType>
Get the base type of a TypeDef by index (1-based).
Sourcepub fn get_interfaces(&self, type_def_index: u32) -> Vec<ResolvedType>
pub fn get_interfaces(&self, type_def_index: u32) -> Vec<ResolvedType>
Get all interfaces implemented by a TypeDef (1-based index).
Sourcepub fn get_type_methods(&self, type_def_index: u32) -> Vec<(u32, &MethodDefRow)>
pub fn get_type_methods(&self, type_def_index: u32) -> Vec<(u32, &MethodDefRow)>
Get methods belonging to a TypeDef (1-based index).
Sourcepub fn get_type_fields(&self, type_def_index: u32) -> Vec<(u32, &FieldRow)>
pub fn get_type_fields(&self, type_def_index: u32) -> Vec<(u32, &FieldRow)>
Get fields belonging to a TypeDef (1-based index).
Sourcepub fn find_type(
&self,
name: &str,
namespace: Option<&str>,
) -> Option<(u32, &TypeDefRow)>
pub fn find_type( &self, name: &str, namespace: Option<&str>, ) -> Option<(u32, &TypeDefRow)>
Find a TypeDef by name (exact match).
Sourcepub fn get_method_owner(&self, method_index: u32) -> Option<(u32, &TypeDefRow)>
pub fn get_method_owner(&self, method_index: u32) -> Option<(u32, &TypeDefRow)>
Get the owning type of a method (1-based method index).
Sourcepub fn get_field_owner(&self, field_index: u32) -> Option<(u32, &TypeDefRow)>
pub fn get_field_owner(&self, field_index: u32) -> Option<(u32, &TypeDefRow)>
Get the owning type of a field (1-based field index).
Sourcepub fn validate(&self) -> Vec<String>
pub fn validate(&self) -> Vec<String>
Validate the metadata structure.
Performs structural integrity checks including:
- Required tables are present (Module must have at least 1 row)
- String indices are within bounds
- GUID indices are within bounds
- Blob indices are within bounds
- Table index references are valid
Returns a list of validation errors. An empty list means the metadata is valid.
Sourcepub fn validate_strict(&self) -> Result<()>
pub fn validate_strict(&self) -> Result<()>
Validate that the metadata is structurally correct.
Returns Ok(()) if valid, or Err with the first validation error.