Struct PropertyMapBuilder
pub struct PropertyMapBuilder { /* private fields */ }Expand description
Builder for creating PropertyMap table entries.
PropertyMapBuilder provides a fluent API for creating entries in the PropertyMap
metadata table, which establishes ownership relationships between types and their properties
through contiguous ranges of Property table entries.
§Purpose
The PropertyMap table serves several key functions:
- Property Ownership: Defines which types own which properties
- Range Management: Establishes contiguous ranges of properties owned by types
- Efficient Lookup: Enables O(log n) lookup of properties by owning type
- Property Enumeration: Supports efficient iteration through all properties of a type
- Metadata Organization: Maintains sorted order for optimal access patterns
§Builder Pattern
The builder provides a fluent interface for constructing PropertyMap entries:
let property_map_token = PropertyMapBuilder::new()
.parent(type_token)
.property_list(1) // Starting property index
.build(&mut context)?;§Validation
The builder enforces the following constraints:
- Parent Required: A parent type token must be provided
- Parent Validation: Parent token must be a valid TypeDef table token
- Property List Required: A property list starting index must be provided
- Index Validation: Property list index must be greater than 0
- Token Validation: Parent token row cannot be 0
§Integration
PropertyMap entries integrate with other metadata structures:
- TypeDef: References specific types in the TypeDef table as parent
- Property: Points to starting positions in the Property table for range definition
- PropertyPtr: Supports indirection through PropertyPtr table when present
- Metadata Loading: Establishes property ownership during type loading
Implementations§
§impl PropertyMapBuilder
impl PropertyMapBuilder
pub fn new() -> Self
pub fn new() -> Self
Creates a new PropertyMapBuilder instance.
Returns a builder with all fields unset, ready for configuration through the fluent API methods.
§Examples
let builder = PropertyMapBuilder::new();pub fn parent(self, parent_token: Token) -> Self
pub fn parent(self, parent_token: Token) -> Self
Sets the parent type token that owns the properties.
The parent must be a valid TypeDef token that represents the type that declares and owns the properties in the specified range.
§Arguments
parent_token- Token of the TypeDef table entry
§Examples
let type_token = TypeDefBuilder::new()
.name("PropertyfulClass")
.namespace("MyApp")
.public_class()
.build(&mut context)?;
let builder = PropertyMapBuilder::new()
.parent(type_token);pub fn property_list(self, property_list_index: u32) -> Self
pub fn property_list(self, property_list_index: u32) -> Self
Sets the starting index in the Property table for this type’s properties.
This index defines the beginning of the contiguous range of properties owned by the parent type. The range extends to the next PropertyMap entry’s property_list index (or end of Property table for the final entry).
§Arguments
property_list_index- 1-based index into the Property table
§Examples
let builder = PropertyMapBuilder::new()
.property_list(1); // Start from first propertypub fn build(self, context: &mut BuilderContext) -> Result<Token>
pub fn build(self, context: &mut BuilderContext) -> Result<Token>
Builds the PropertyMap entry and adds it to the assembly.
This method validates all required fields, verifies the parent token is valid, validates the property list index, creates the PropertyMap table entry, and returns the metadata token for the new entry.
§Arguments
context- The builder context for the assembly being modified
§Returns
Returns the metadata token for the newly created PropertyMap entry.
§Errors
Returns an error if:
- The parent token is not set
- The parent token is not a valid TypeDef token
- The parent token row is 0
- The property list index is not set
- The property list index is 0
- There are issues adding the table row
§Examples
let property_map_token = PropertyMapBuilder::new()
.parent(type_token)
.property_list(1)
.build(&mut context)?;
println!("Created PropertyMap with token: {}", property_map_token);Trait Implementations§
§impl Clone for PropertyMapBuilder
impl Clone for PropertyMapBuilder
§fn clone(&self) -> PropertyMapBuilder
fn clone(&self) -> PropertyMapBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for PropertyMapBuilder
impl Debug for PropertyMapBuilder
Auto Trait Implementations§
impl Freeze for PropertyMapBuilder
impl RefUnwindSafe for PropertyMapBuilder
impl Send for PropertyMapBuilder
impl Sync for PropertyMapBuilder
impl Unpin for PropertyMapBuilder
impl UnwindSafe for PropertyMapBuilder
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