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: u32

Row 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: Token

Metadata token for this MethodSpec entry.

Format: 0x2BXXXXXX where XXXXXX is the row ID. Used for cross-referencing this entry from other metadata structures.

§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.

§method: CodedIndex

Raw 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: u32

Raw 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

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 to CilTypeReference
  • blob - The blob heap containing the instantiation signature
  • types - 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

§

fn clone(&self) -> MethodSpecRaw

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 MethodSpecRaw

§

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

Formats the value using the given formatter. Read more
§

impl RowReadable for MethodSpecRaw

§

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:

  1. Method (2-4 bytes): MethodDefOrRef coded index to the generic method
  2. Instantiation (2-4 bytes): Index into blob heap containing signature
§Arguments
  • data - Binary data containing the table
  • offset - 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

§

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: MethodDefOrRef coded index (generic method reference)
  • instantiation: Blob heap index (type argument signature)
§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 MethodSpecRaw

§

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 on MethodDefOrRef coded 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§

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.