Struct StateMachineMethodRaw

pub struct StateMachineMethodRaw {
    pub rid: u32,
    pub token: Token,
    pub offset: usize,
    pub move_next_method: u32,
    pub kickoff_method: u32,
}
Expand description

Raw binary representation of a StateMachineMethod table entry

This structure matches the exact binary layout of StateMachineMethod table entries in the metadata tables stream. Both fields contain unresolved indices into the MethodDef table that must be resolved during conversion to the owned StateMachineMethod variant.

§Binary Format

Each StateMachineMethod table entry consists of:

  • MoveNextMethod (4 bytes): MethodDef table index of the compiler-generated MoveNext method
  • KickoffMethod (4 bytes): MethodDef table index of the original user method

§State Machine Context

When compilers generate state machines for async/await or yield return patterns:

  1. The original method becomes the “kickoff” method that initializes the state machine
  2. A new MoveNext method contains the actual implementation logic
  3. This table provides the bidirectional mapping between these methods

§Constraints

  • Table must be sorted by MoveNextMethod column
  • No duplicate MoveNextMethod values allowed
  • No duplicate KickoffMethod values allowed
  • Both indices must reference valid MethodDef entries

§References

Fields§

§rid: u32

Row identifier (1-based index in the table)

§token: Token

Metadata token for this StateMachineMethod entry

§offset: usize

Byte offset of this row in the original metadata stream

§move_next_method: u32

Index into MethodDef table for the compiler-generated MoveNext method

References the state machine’s MoveNext method that contains the actual implementation logic. This method is generated by the compiler and contains the state machine’s execution logic.

§kickoff_method: u32

Index into MethodDef table for the original user-written method

References the kickoff method that was originally written by the developer. This method initializes and starts the state machine when called.

Implementations§

§

impl StateMachineMethodRaw

pub fn to_owned(&self, method_map: &MethodMap) -> Result<StateMachineMethodRc>

Converts this raw StateMachineMethod entry to an owned StateMachineMethod instance

This method resolves the raw StateMachineMethod entry to create a complete StateMachineMethod object by resolving the MethodDef table indices to actual method references from the method map. Both method references are resolved using the provided method map.

§Parameters
  • method_map: Reference to the method map containing resolved method references
§Returns

Returns Ok(StateMachineMethodRc) with the resolved state machine method mapping data, or an error if either method reference cannot be resolved.

§Errors

Returns TypeNotFound if either the move_next_method or kickoff_method cannot be resolved from the map.

§Example
let mapping_raw = StateMachineMethodRaw {
    rid: 1,
    token: Token::new(0x36000001),
    offset: 0,
    move_next_method: 123,  // MethodDef table index
    kickoff_method: 45,     // MethodDef table index
};

let mapping = mapping_raw.to_owned(method_map)?;

Trait Implementations§

§

impl Clone for StateMachineMethodRaw

§

fn clone(&self) -> StateMachineMethodRaw

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 StateMachineMethodRaw

§

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

Formats the value using the given formatter. Read more
§

impl RowReadable for StateMachineMethodRaw

§

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

Reads and parses a single row from the provided byte buffer. Read more
§

impl RowWritable for StateMachineMethodRaw

§

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

Write a StateMachineMethod table row to binary data

Serializes one StateMachineMethod table entry to the metadata tables stream format, handling variable-width MethodDef table indexes based on the table size information.

§Arguments
  • data - Target binary buffer for metadata tables stream
  • offset - Current write position (updated after writing)
  • _rid - Row identifier for this state machine method entry (unused for StateMachineMethod)
  • sizes - Table sizing information for writing table indexes
§Returns
  • Ok(()) - Successfully serialized state machine method row
  • Err(crate::Error) - If buffer is too small or write fails
§Binary Format

Fields are written in the exact order specified by the Portable PDB specification:

  1. MoveNext MethodDef index (2/4 bytes, little-endian)
  2. Kickoff MethodDef index (2/4 bytes, little-endian)
§

impl TableRow for StateMachineMethodRaw

§

fn row_size(sizes: &TableInfoRef) -> u32

Calculate the row size for StateMachineMethod table entries

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

§Size Breakdown
  • move_next_method: 2 or 4 bytes (table index into MethodDef table)
  • kickoff_method: 2 or 4 bytes (table index into MethodDef 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.