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:
- Data arrives from the network as a raw byte stream.
- The system identifies the message type at runtime via a string-based name (topic).
- The system must then locate the corresponding type-erased
Synapseand restore its concrete Rust types to decode the bytes and trigger the appropriateReactants.
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.