Struct DocumentRaw

pub struct DocumentRaw {
    pub rid: u32,
    pub token: Token,
    pub offset: usize,
    pub name: u32,
    pub hash_algorithm: u32,
    pub hash: u32,
    pub language: u32,
}
Expand description

Raw Document table row with unresolved heap indices

Represents the binary format of a Document metadata table entry (table ID 0x30) as stored in the metadata tables stream. All heap indices are stored as raw values that must be resolved using the appropriate heap context to access the actual data.

The Document table associates source documents with debug information throughout the assembly, providing a mechanism for mapping IL instructions back to source code locations during debugging sessions.

§Reference

Fields§

§rid: u32

Row identifier within the Document metadata table

The 1-based index of this document row within the table. Used to generate the metadata token and for table iteration.

§token: Token

Metadata token for this document row

Combines the table identifier (0x30 for Document) with the row ID to create a unique token. Format: 0x30000000 | rid

§offset: usize

Byte offset of this row within the metadata tables stream

Physical location of the raw document data within the metadata binary format. Used for debugging and low-level metadata analysis.

§name: u32

Blob heap index for the document name/path (unresolved)

Index into the blob heap containing the document name, typically a file path or URI that identifies the source document. The blob format is specific to document names and may contain path separators and components.

§hash_algorithm: u32

GUID heap index for the hash algorithm identifier (unresolved)

Index into the GUID heap for the hash algorithm used to compute the document hash. Common algorithms include SHA-1, SHA-256, and others. Must be resolved using GUID heap lookup.

§hash: u32

Blob heap index for the document content hash (unresolved)

Index into the blob heap containing the hash value of the document content computed using the specified hash algorithm. Used for integrity verification and change detection. A value of 0 indicates no hash is available.

§language: u32

GUID heap index for the source language identifier (unresolved)

Index into the GUID heap for the programming language used in this document. Common languages include C#, VB.NET, F#, and others. Must be resolved using GUID heap lookup.

Implementations§

§

impl DocumentRaw

pub fn to_owned( &self, _strings: &Strings<'_>, blobs: &Blob<'_>, guids: &Guid<'_>, ) -> Result<DocumentRc>

Convert a raw Document to an owned Document with resolved heap data

This method transforms the raw table entry into a fully usable document by:

  1. Resolving the name blob to extract the document path
  2. Resolving the hash algorithm GUID to identify the hash type
  3. Resolving the hash blob to get the actual hash bytes
  4. Resolving the language GUID to identify the programming language
  5. Creating an owned Document with all resolved data

The method performs comprehensive validation to ensure metadata integrity.

§Arguments
  • strings - String heap for resolving string indices
  • blobs - Blob heap for resolving blob indices (name and hash)
  • guids - GUID heap for resolving GUID indices (hash algorithm and language)
§Returns

Returns Ok(DocumentRc) with the resolved document data, or an error if:

  • Any heap index is invalid or out of bounds
  • The document name blob has an invalid format
  • Required heap data is missing or corrupted
§Errors

Returns an error if:

  • Blob heap access fails for name or hash data
  • GUID heap access fails for hash algorithm or language GUIDs
  • Any heap index is out of bounds
§Example
let document_raw = DocumentRaw {
    rid: 1,
    token: Token::new(0x30000001),
    offset: 0,
    name: 42,        // blob index
    hash_algorithm: 1, // GUID index
    hash: 100,      // blob index
    language: 1,    // GUID index
};

// let document = document_raw.to_owned(&strings, &blobs, &guids)?;
§Errors

Returns an error if heap lookups fail or if the data is malformed.

Trait Implementations§

§

impl Clone for DocumentRaw

§

fn clone(&self) -> DocumentRaw

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 DocumentRaw

§

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

Formats the value using the given formatter. Read more
§

impl RowReadable for DocumentRaw

§

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 DocumentRaw

§

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

Write a Document table row to binary data

Serializes one Document table entry to the metadata tables stream format, handling variable-width heap indexes based on the heap size information.

§Arguments
  • data - Target binary buffer for metadata tables stream
  • offset - Current write position (updated after writing)
  • _rid - Row identifier for this document entry (unused for Document)
  • sizes - Table sizing information for writing heap indexes
§Returns
  • Ok(()) - Successfully serialized document 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. Name blob index (2/4 bytes, little-endian)
  2. Hash algorithm GUID index (2/4 bytes, little-endian)
  3. Hash blob index (2/4 bytes, little-endian)
  4. Language GUID index (2/4 bytes, little-endian)
§

impl TableRow for DocumentRaw

§

fn row_size(sizes: &TableInfoRef) -> u32

Calculate the row size for Document table entries

Returns the total byte size of a single Document table row based on the table configuration. The size varies depending on the size of heap indexes in the metadata.

§Size Breakdown
  • name: 2 or 4 bytes (blob heap index for document name/path)
  • hash_algorithm: 2 or 4 bytes (GUID heap index for hash algorithm)
  • hash: 2 or 4 bytes (blob heap index for document content hash)
  • language: 2 or 4 bytes (GUID heap index for source language)

Total: 8-16 bytes depending on heap size configuration

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.