Struct StateMachineMethodBuilder
pub struct StateMachineMethodBuilder { /* private fields */ }Expand description
Builder for constructing StateMachineMethod table entries
Provides a fluent interface for building StateMachineMethod metadata table entries.
These entries map compiler-generated state machine methods back to their original
user-written methods, enabling proper debugging of async/await and iterator methods.
§Required Fields
move_next_method: MethodDef RID for the compiler-generated MoveNext methodkickoff_method: MethodDef RID for the original user-written 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
§Examples
use dotscope::prelude::*;
// Map async method to its state machine
let async_mapping = StateMachineMethodBuilder::new()
.move_next_method(123) // Compiler-generated MoveNext method
.kickoff_method(45) // Original async method
.build(&mut assembly)?;
// Map iterator method to its state machine
let iterator_mapping = StateMachineMethodBuilder::new()
.move_next_method(200) // Compiler-generated MoveNext method
.kickoff_method(78) // Original iterator method
.build(&mut assembly)?;Implementations§
§impl StateMachineMethodBuilder
impl StateMachineMethodBuilder
pub fn new() -> Self
pub fn new() -> Self
Creates a new StateMachineMethodBuilder with default values
Initializes a new builder instance with all fields unset. The caller must provide both required fields before calling build().
§Returns
A new StateMachineMethodBuilder instance ready for configuration
§Examples
use dotscope::prelude::*;
let builder = StateMachineMethodBuilder::new();pub fn move_next_method(self, move_next_method: u32) -> Self
pub fn move_next_method(self, move_next_method: u32) -> Self
Sets the MoveNext method RID
Specifies the MethodDef RID for the compiler-generated MoveNext method that contains the actual state machine implementation logic.
§Parameters
move_next_method: MethodDef RID for the MoveNext method
§Returns
Self for method chaining
§Examples
use dotscope::prelude::*;
let builder = StateMachineMethodBuilder::new()
.move_next_method(123); // RID of compiler-generated methodpub fn kickoff_method(self, kickoff_method: u32) -> Self
pub fn kickoff_method(self, kickoff_method: u32) -> Self
Sets the kickoff method RID
Specifies the MethodDef RID for the original user-written method that was transformed into a state machine by the compiler.
§Parameters
kickoff_method: MethodDef RID for the original method
§Returns
Self for method chaining
§Examples
use dotscope::prelude::*;
let builder = StateMachineMethodBuilder::new()
.kickoff_method(45); // RID of original user methodpub fn build(self, assembly: &mut CilAssembly) -> Result<ChangeRefRc>
pub fn build(self, assembly: &mut CilAssembly) -> Result<ChangeRefRc>
Builds and adds the StateMachineMethod entry to the metadata
Validates all required fields, creates the StateMachineMethod table entry,
and adds it to the assembly. Returns a token that can be used
to reference this state machine method mapping.
§Parameters
assembly: Mutable reference to the CilAssembly
§Returns
Ok(Token): Token referencing the created state machine method mappingErr(Error): If validation fails or table operations fail
§Errors
- Missing required field (move_next_method or kickoff_method)
- Table operations fail due to metadata constraints
- State machine method validation failed
§Examples
use dotscope::prelude::*;
let mut assembly = CilAssembly::new(view);
let token = StateMachineMethodBuilder::new()
.move_next_method(123)
.kickoff_method(45)
.build(&mut assembly)?;Trait Implementations§
§impl Clone for StateMachineMethodBuilder
impl Clone for StateMachineMethodBuilder
§fn clone(&self) -> StateMachineMethodBuilder
fn clone(&self) -> StateMachineMethodBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for StateMachineMethodBuilder
impl Debug for StateMachineMethodBuilder
§impl Default for StateMachineMethodBuilder
impl Default for StateMachineMethodBuilder
§fn default() -> Self
fn default() -> Self
Creates a default StateMachineMethodBuilder
Equivalent to calling StateMachineMethodBuilder::new().
Auto Trait Implementations§
impl Freeze for StateMachineMethodBuilder
impl RefUnwindSafe for StateMachineMethodBuilder
impl Send for StateMachineMethodBuilder
impl Sync for StateMachineMethodBuilder
impl Unpin for StateMachineMethodBuilder
impl UnsafeUnpin for StateMachineMethodBuilder
impl UnwindSafe for StateMachineMethodBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.