// Copyright 2025 Alecks Gates
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//! # 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.