plexor-core 0.1.0-alpha.2

Core library for the rust implementation of the Plexo distributed system architecture, providing the fundamental Plexus, Neuron, Codec, and Axon abstractions.
Documentation
// 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/.

//! Error types for the erasure module.

use std::any::TypeId;
use thiserror::Error;

/// Errors that can occur when working with type-erased wrappers
#[derive(Error, Debug)]
pub enum ErasureError {
    /// Type mismatch when trying to convert a type-erased neuron to a specific type
    #[error(
        "Neuron type mismatch: expected payload type {expected_payload_type:?} and codec type {expected_codec_type:?}, but found payload type {actual_payload_type:?} and codec type {actual_codec_type:?}"
    )]
    NeuronTypeMismatch {
        expected_payload_type: TypeId,
        expected_codec_type: TypeId,
        actual_payload_type: TypeId,
        actual_codec_type: TypeId,
    },

    /// Type mismatch when trying to convert a type-erased payload to a specific type
    #[error(
        "Payload type mismatch: expected payload type {expected_payload_type:?} and codec type {expected_codec_type:?}, but found payload type {actual_payload_type:?} and codec type {actual_codec_type:?}"
    )]
    PayloadTypeMismatch {
        expected_payload_type: TypeId,
        expected_codec_type: TypeId,
        actual_payload_type: TypeId,
        actual_codec_type: TypeId,
    },

    /// Type mismatch when trying to convert a type-erased synapse to a specific type
    #[error(
        "Synapse type mismatch: expected payload type {expected_payload_type:?} and codec type {expected_codec_type:?}, but found payload type {actual_payload_type:?} and codec type {actual_codec_type:?}"
    )]
    SynapseTypeMismatch {
        expected_payload_type: TypeId,
        expected_codec_type: TypeId,
        actual_payload_type: TypeId,
        actual_codec_type: TypeId,
    },
}

/// Result type for erasure operations
pub type ErasureResult<T> = Result<T, ErasureError>;