use std::borrow::Cow;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum Error {
#[error("actor error: {0}")]
Actor(String),
#[error("resource exhausted: {0}")]
ResourceExhausted(String),
#[error("serialization failed: {0}")]
Serialization(String),
#[error("internal error: {0}")]
Internal(String),
}
impl Error {
pub fn actor(message: impl Into<Cow<'static, str>>) -> Self {
Self::Actor(message.into().into_owned())
}
pub fn resource_exhausted(message: impl Into<Cow<'static, str>>) -> Self {
Self::ResourceExhausted(message.into().into_owned())
}
pub fn serialization(message: impl Into<Cow<'static, str>>) -> Self {
Self::Serialization(message.into().into_owned())
}
pub fn internal(message: impl Into<Cow<'static, str>>) -> Self {
Self::Internal(message.into().into_owned())
}
}