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

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

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

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 event

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

§

fn clone(&self) -> EventMapBuilder

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 EventMapBuilder

§

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

Formats the value using the given formatter. Read more
§

impl Default for EventMapBuilder

§

fn default() -> Self

Returns the “default value” for a type. Read more

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.