Struct LocalScopeRaw

pub struct LocalScopeRaw {
    pub rid: u32,
    pub token: Token,
    pub offset: usize,
    pub method: u32,
    pub import_scope: u32,
    pub variable_list: u32,
    pub constant_list: u32,
    pub start_offset: u32,
    pub length: u32,
}
Expand description

Raw binary representation of a LocalScope table entry

This structure matches the exact binary layout of LocalScope table entries in the metadata tables stream. All table references remain as unresolved indices that must be resolved through the appropriate tables during the conversion to the owned LocalScope variant.

§Binary Format

Each LocalScope table entry consists of:

  • Method: Simple index into MethodDef table
  • ImportScope: Simple index into ImportScope table
  • VariableList: Simple index into LocalVariable table
  • ConstantList: Simple index into LocalConstant table
  • StartOffset: 4-byte unsigned integer (IL offset)
  • Length: 4-byte unsigned integer (scope length in bytes)

Fields§

§rid: u32

Row identifier (1-based index in the table)

§token: Token

Metadata token for this LocalScope entry

§offset: usize

Byte offset of this row in the original metadata stream

§method: u32

Simple index into MethodDef table

Identifies the method that contains this local scope. This is always a valid method reference as local scopes must belong to a method.

§import_scope: u32

Simple index into ImportScope table

References the import scope that provides the namespace context for this local scope. May be 0 if no specific import context is required.

§variable_list: u32

Simple index into LocalVariable table

Points to the first local variable that belongs to this scope. Variables are stored consecutively, so this serves as a range start. May be 0 if this scope contains no variables.

§constant_list: u32

Simple index into LocalConstant table

Points to the first local constant that belongs to this scope. Constants are stored consecutively, so this serves as a range start. May be 0 if this scope contains no constants.

§start_offset: u32

IL instruction offset where this scope begins

Specifies the byte offset within the method’s IL code where the variables and constants in this scope become active.

§length: u32

Length of this scope in IL instruction bytes

Specifies how many bytes of IL code this scope covers. The scope extends from start_offset to (start_offset + length).

Implementations§

§

impl LocalScopeRaw

pub fn to_owned( &self, methods: &MethodMap, import_scopes: &ImportScopeMap, variables: &LocalVariableMap, constants: &LocalConstantMap, scope_table: &MetadataTable<'_, LocalScopeRaw>, ) -> Result<LocalScopeRc>

Converts this raw LocalScope entry to an owned LocalScope instance

This method resolves the raw LocalScope entry to create a complete LocalScope object by resolving all table references and building the variable and constant lists using range determination based on the next scope’s starting indices.

§Parameters
  • methods: Map of resolved methods for method reference resolution
  • import_scopes: Map of resolved import scopes for import scope resolution
  • variables: Map of resolved local variables for building variable lists
  • constants: Map of resolved local constants for building constant lists
  • scope_table: The raw LocalScope table for looking up next scope indices
§Returns

Returns Ok(LocalScopeRc) with the resolved scope data, or an error if any references are invalid or point to malformed data.

§Errors

Returns an error if any references are invalid or point to malformed data.

Trait Implementations§

§

impl Clone for LocalScopeRaw

§

fn clone(&self) -> LocalScopeRaw

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 LocalScopeRaw

§

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

Formats the value using the given formatter. Read more
§

impl RowReadable for LocalScopeRaw

§

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 LocalScopeRaw

§

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

Write a LocalScope table row to binary data

Serializes one LocalScope table entry to the metadata tables stream format, handling variable-width 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 local scope entry (unused for LocalScope)
  • sizes - Table sizing information for writing table indexes
§Returns
  • Ok(()) - Successfully serialized local scope 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. Method table index (2/4 bytes, little-endian)
  2. ImportScope table index (2/4 bytes, little-endian, 0 = no import scope)
  3. LocalVariable table index (2/4 bytes, little-endian, 0 = no variables)
  4. LocalConstant table index (2/4 bytes, little-endian, 0 = no constants)
  5. Start offset (4 bytes, little-endian)
  6. Length (4 bytes, little-endian)
§

impl TableRow for LocalScopeRaw

§

fn row_size(sizes: &TableInfoRef) -> u32

Calculate the byte size of a LocalScope table row

Returns the total size of one row in the LocalScope table, including:

  • method: 2 or 4 bytes (MethodDef table index)
  • import_scope: 2 or 4 bytes (ImportScope table index)
  • variable_list: 2 or 4 bytes (LocalVariable table index)
  • constant_list: 2 or 4 bytes (LocalConstant table index)
  • start_offset: 4 bytes
  • length: 4 bytes

The index sizes depend on the metadata table requirements.

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.