aspartam 0.1.0

Minimalistic actor framework based on tokio, inspired by actix
Documentation
//! Stores aspartam's error type

use crate::{actor::Actor, message_queue::QueuePayload};
use thiserror::Error;
use tokio::sync::mpsc::error::SendError as TokioSendError;
use tokio::sync::oneshot::error::RecvError as TokioRecvError;

#[derive(Error, Debug, PartialEq, Eq)]
/// The error type used by actor interactions
pub enum ActorError {
    #[error("Failed to enqueue new message for actor. Actor has most likely stopped.")]
    /// Failed to enqueue new message for actor. Actor has most likely stopped.
    CannotSend,
    #[error("The actor has most likely stopped before the message could be handled.")]
    /// The actor has most likely stopped before the message could be handled.
    MessageLost,
}

impl<T> From<TokioSendError<QueuePayload<T>>> for ActorError
where
    T: Actor,
{
    fn from(_: TokioSendError<QueuePayload<T>>) -> Self {
        Self::CannotSend
    }
}

impl From<TokioRecvError> for ActorError {
    fn from(_: TokioRecvError) -> Self {
        Self::MessageLost
    }
}