Struct MethodPtrBuilder

pub struct MethodPtrBuilder { /* private fields */ }
Expand description

Builder for constructing MethodPtr table entries

Provides a fluent interface for building MethodPtr metadata table entries. These entries provide indirection for method access when logical and physical method ordering differs, enabling method table optimizations and edit-and-continue.

§Required Fields

  • method: MethodDef table RID that this pointer references

§Indirection Context

The MethodPtr table provides a mapping layer between logical method references and physical MethodDef table entries. This enables:

  • Method reordering for metadata optimization
  • Edit-and-continue method additions without breaking references
  • Runtime method hot-reload and debugging interception
  • Incremental compilation with stable method references

§Examples

use dotscope::prelude::*;

// Create method pointer for method reordering
let ptr1 = MethodPtrBuilder::new()
    .method(15)  // Points to MethodDef table entry 15
    .build(&mut context)?;

// Create pointer for hot-reload scenario
let ptr2 = MethodPtrBuilder::new()
    .method(42)  // Points to MethodDef table entry 42
    .build(&mut context)?;

// Multiple pointers for complex reordering
let ptr3 = MethodPtrBuilder::new()
    .method(7)   // Points to MethodDef table entry 7
    .build(&mut context)?;

Implementations§

§

impl MethodPtrBuilder

pub fn new() -> Self

Creates a new MethodPtrBuilder with default values

Initializes a new builder instance with all fields unset. The caller must provide the required method RID before calling build().

§Returns

A new MethodPtrBuilder instance ready for configuration

§Examples
use dotscope::prelude::*;

let builder = MethodPtrBuilder::new();

pub fn method(self, method: u32) -> Self

Sets the MethodDef table RID

Specifies which MethodDef table entry this pointer references. This creates the indirection mapping from the MethodPtr RID (logical index) to the actual MethodDef table entry (physical index).

§Parameters
  • method: The MethodDef table RID to reference
§Returns

Self for method chaining

§Examples
use dotscope::prelude::*;

// Point to first method
let builder = MethodPtrBuilder::new()
    .method(1);

// Point to a later method for reordering
let builder = MethodPtrBuilder::new()
    .method(25);

pub fn build(self, context: &mut BuilderContext) -> Result<Token>

Builds and adds the MethodPtr entry to the metadata

Validates all required fields, creates the MethodPtr table entry, and adds it to the builder context. Returns a token that can be used to reference this method pointer entry.

§Parameters
  • context: Mutable reference to the builder context
§Returns
  • Ok(Token): Token referencing the created method pointer entry
  • Err(Error): If validation fails or table operations fail
§Errors
  • Missing required field (method RID)
  • Table operations fail due to metadata constraints
§Examples
use dotscope::prelude::*;

let mut context = BuilderContext::new();
let token = MethodPtrBuilder::new()
    .method(8)
    .build(&mut context)?;

Trait Implementations§

§

impl Clone for MethodPtrBuilder

§

fn clone(&self) -> MethodPtrBuilder

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 MethodPtrBuilder

§

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

Formats the value using the given formatter. Read more
§

impl Default for MethodPtrBuilder

§

fn default() -> Self

Creates a default MethodPtrBuilder

Equivalent to calling MethodPtrBuilder::new().

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.