Skip to main content

Module erasure

Module erasure 

Source
Expand description

§Type Erasure Module

This module provides the mechanisms for bridging type-agnostic transport layers with type-specific processing logic.

§Rationale for unsafe Transmutes

Plexor uses unsafe transmutes as a fundamental architectural requirement to achieve a “Universal Plexus” capable of routing an infinite variety of user-defined types.

This is particularly important for External Ganglia (e.g., ZMQ, HTTP, WebSockets). In these cases:

  1. Data arrives from the network as a raw byte stream.
  2. The system identifies the message type at runtime via a string-based name (topic).
  3. The system must then locate the corresponding type-erased Synapse and restore its concrete Rust types to decode the bytes and trigger the appropriate Reactants.

Because these types are not known at compile time by the transport layer, and the standard Any trait has limitations in restoring complex generic types across trait boundaries, we use TypeId verification to ensure runtime safety before using unsafe transmutes to restore the type-specific pointers. This avoids the performance penalties of reflection while overcoming the constraints of the type system.

Modules§

error
Error types for the erasure module.
neuron
Type-erased versions of neuron traits.
payload
Type-erased versions of payload traits.
reactant
Type-erased versions of reactant traits.
synapse
Type-erased versions of synapse traits.