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):MethodDeftable index of the compiler-generatedMoveNextmethodKickoffMethod(4 bytes):MethodDeftable index of the original user method
§State Machine Context
When compilers generate state machines for async/await or yield return patterns:
- The original method becomes the “kickoff” method that initializes the state machine
- A new
MoveNextmethod contains the actual implementation logic - This table provides the bidirectional mapping between these methods
§Constraints
- Table must be sorted by
MoveNextMethodcolumn - No duplicate
MoveNextMethodvalues allowed - No duplicate
KickoffMethodvalues allowed - Both indices must reference valid
MethodDefentries
§References
Fields§
§rid: u32Row identifier (1-based index in the table)
token: TokenMetadata token for this StateMachineMethod entry
offset: usizeByte offset of this row in the original metadata stream
move_next_method: u32Index 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: u32Index 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
impl StateMachineMethodRaw
pub fn to_owned(&self, method_map: &MethodMap) -> Result<StateMachineMethodRc>
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
impl Clone for StateMachineMethodRaw
§fn clone(&self) -> StateMachineMethodRaw
fn clone(&self) -> StateMachineMethodRaw
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for StateMachineMethodRaw
impl Debug for StateMachineMethodRaw
§impl RowReadable for StateMachineMethodRaw
impl RowReadable for StateMachineMethodRaw
§impl RowWritable for StateMachineMethodRaw
impl RowWritable for StateMachineMethodRaw
§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<()>
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 streamoffset- Current write position (updated after writing)_rid- Row identifier for this state machine method entry (unused forStateMachineMethod)sizes- Table sizing information for writing table indexes
§Returns
Ok(())- Successfully serialized state machine method rowErr(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:
- MoveNext MethodDef index (2/4 bytes, little-endian)
- Kickoff MethodDef index (2/4 bytes, little-endian)
§impl TableRow for StateMachineMethodRaw
impl TableRow for StateMachineMethodRaw
§fn row_size(sizes: &TableInfoRef) -> u32
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 intoMethodDeftable)kickoff_method: 2 or 4 bytes (table index intoMethodDeftable)
Total: 4-8 bytes depending on table index size configuration
Auto Trait Implementations§
impl Freeze for StateMachineMethodRaw
impl RefUnwindSafe for StateMachineMethodRaw
impl Send for StateMachineMethodRaw
impl Sync for StateMachineMethodRaw
impl Unpin for StateMachineMethodRaw
impl UnwindSafe for StateMachineMethodRaw
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