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
MethodDeftable ImportScope: Simple index intoImportScopetableVariableList: Simple index intoLocalVariabletableConstantList: Simple index intoLocalConstanttableStartOffset: 4-byte unsigned integer (IL offset)Length: 4-byte unsigned integer (scope length in bytes)
Fields§
§rid: u32Row identifier (1-based index in the table)
token: TokenMetadata token for this LocalScope entry
offset: usizeByte offset of this row in the original metadata stream
method: u32Simple 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: u32Simple 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: u32Simple 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: u32Simple 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: u32IL 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: u32Length 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
impl LocalScopeRaw
pub fn to_owned(
&self,
methods: &MethodMap,
import_scopes: &ImportScopeMap,
variables: &LocalVariableMap,
constants: &LocalConstantMap,
scope_table: &MetadataTable<'_, LocalScopeRaw>,
) -> Result<LocalScopeRc>
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 resolutionimport_scopes: Map of resolved import scopes for import scope resolutionvariables: Map of resolved local variables for building variable listsconstants: Map of resolved local constants for building constant listsscope_table: The rawLocalScopetable 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
impl Clone for LocalScopeRaw
§fn clone(&self) -> LocalScopeRaw
fn clone(&self) -> LocalScopeRaw
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for LocalScopeRaw
impl Debug for LocalScopeRaw
§impl RowReadable for LocalScopeRaw
impl RowReadable for LocalScopeRaw
§impl RowWritable for LocalScopeRaw
impl RowWritable for LocalScopeRaw
§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 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 streamoffset- Current write position (updated after writing)_rid- Row identifier for this local scope entry (unused forLocalScope)sizes- Table sizing information for writing table indexes
§Returns
Ok(())- Successfully serialized local scope 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:
- Method table index (2/4 bytes, little-endian)
- ImportScope table index (2/4 bytes, little-endian, 0 = no import scope)
- LocalVariable table index (2/4 bytes, little-endian, 0 = no variables)
- LocalConstant table index (2/4 bytes, little-endian, 0 = no constants)
- Start offset (4 bytes, little-endian)
- Length (4 bytes, little-endian)
§impl TableRow for LocalScopeRaw
impl TableRow for LocalScopeRaw
§fn row_size(sizes: &TableInfoRef) -> u32
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§
impl Freeze for LocalScopeRaw
impl RefUnwindSafe for LocalScopeRaw
impl Send for LocalScopeRaw
impl Sync for LocalScopeRaw
impl Unpin for LocalScopeRaw
impl UnwindSafe for LocalScopeRaw
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