Struct MethodSpecRaw
pub struct MethodSpecRaw {
pub rid: u32,
pub token: Token,
pub offset: usize,
pub method: CodedIndex,
pub instantiation: u32,
}Expand description
Raw representation of a MethodSpec table entry with unresolved indexes.
This structure represents an unprocessed entry from the MethodSpec metadata table
(ID 0x2B), which defines instantiations of generic methods with concrete type arguments.
It contains raw index values that require resolution to actual metadata objects.
§Purpose
The MethodSpec table enables generic method instantiation by:
- Referencing the generic method definition or member reference
- Specifying the blob heap location of the instantiation signature
- Providing the foundation for runtime generic method dispatch
§Raw vs Owned
This raw variant is used during initial metadata parsing and contains:
- Unresolved table indexes requiring lookup
- Minimal memory footprint for storage
- Direct representation of file format
Use MethodSpec for resolved references and runtime access.
§ECMA-335 Reference
Corresponds to ECMA-335 §II.22.29 MethodSpec table structure.
Fields§
§rid: u32Row identifier within the MethodSpec table.
This 1-based index uniquely identifies this entry within the table. Combined with table ID 0x2B, forms the metadata token 0x2BXXXXXX.
token: TokenMetadata token for this MethodSpec entry.
Format: 0x2BXXXXXX where XXXXXX is the row ID. Used for cross-referencing this entry from other metadata structures.
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.
method: CodedIndexRaw MethodDefOrRef coded index to the generic method.
This coded index identifies the generic method that will be instantiated:
- Low 1 bit: Table tag (0=MethodDef, 1=MemberRef)
- High bits: Row index in the target table
Must be resolved using the appropriate table to get the actual method reference. Index size depends on table sizes (2 or 4 bytes).
instantiation: u32Raw index into the blob heap containing the instantiation signature.
Points to a MethodSpecSignature in the blob heap
that specifies the concrete type arguments for the generic method parameters.
The signature format follows ECMA-335 §II.23.2.15 and contains:
- Generic argument count
- Type signatures for each generic argument
Index size depends on blob heap size (2 or 4 bytes).
Implementations§
§impl MethodSpecRaw
impl MethodSpecRaw
pub fn to_owned_and_apply<F>(
&self,
get_ref: F,
blob: &Blob<'_>,
types: &Arc<TypeRegistry>,
) -> Result<MethodSpecRc>
pub fn to_owned_and_apply<F>( &self, get_ref: F, blob: &Blob<'_>, types: &Arc<TypeRegistry>, ) -> Result<MethodSpecRc>
Converts this raw entry to an owned MethodSpec and applies the generic instantiation.
This method combines the functionality of resolving indexes, parsing the signature,
resolving generic arguments, and applying them to the target method all in one step.
It’s the primary method for processing MethodSpec entries during metadata loading.
§Arguments
get_ref- Function to resolve coded index toCilTypeReferenceblob- The blob heap containing the instantiation signaturetypes- The type registry for resolving generic argument types
§Returns
A reference-counted MethodSpecRc containing the resolved and applied entry.
§Errors
- Method token is invalid or cannot be resolved
- Referenced method or member reference cannot be resolved
- Blob heap entry is malformed or missing
- Method specification signature cannot be parsed
- Generic type arguments cannot be resolved
- Target method cannot accept the generic instantiation
Trait Implementations§
§impl Clone for MethodSpecRaw
impl Clone for MethodSpecRaw
§fn clone(&self) -> MethodSpecRaw
fn clone(&self) -> MethodSpecRaw
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for MethodSpecRaw
impl Debug for MethodSpecRaw
§impl RowReadable for MethodSpecRaw
impl RowReadable for MethodSpecRaw
§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 MethodSpec table row from binary data.
Parses the binary representation according to ECMA-335 §II.22.29:
- Method (2-4 bytes):
MethodDefOrRefcoded index to the generic method - Instantiation (2-4 bytes): Index into blob heap containing signature
§Arguments
data- Binary data containing the tableoffset- Current read position (updated by this method)rid- Row identifier for this entry (1-based)sizes- Table size information for proper index width calculation
§Returns
Parsed MethodSpecRaw instance with populated fields
§Errors
Returns an error if:
- Insufficient data remaining at offset
- Invalid coded index encoding
- Data corruption or malformed structure
§impl RowWritable for MethodSpecRaw
impl RowWritable for MethodSpecRaw
§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 MethodSpec table row to binary format
Writes the row data according to ECMA-335 §II.22.29 specification:
method:MethodDefOrRefcoded index (generic method reference)instantiation: Blob heap index (type argument signature)
§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 MethodSpecRaw
impl TableRow for MethodSpecRaw
§fn row_size(sizes: &TableInfoRef) -> u32
fn row_size(sizes: &TableInfoRef) -> u32
Calculates the byte size of a MethodSpec table row.
The row size depends on the metadata table sizes and is calculated as:
method: 2 or 4 bytes (depends onMethodDefOrRefcoded index size)instantiation: 2 or 4 bytes (depends on blob heap size)
§Arguments
sizes- Table size information for calculating index widths
§Returns
Total byte size of one table row
Auto Trait Implementations§
impl Freeze for MethodSpecRaw
impl RefUnwindSafe for MethodSpecRaw
impl Send for MethodSpecRaw
impl Sync for MethodSpecRaw
impl Unpin for MethodSpecRaw
impl UnwindSafe for MethodSpecRaw
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