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