pub type SimResult<Ok = ()> = Result<Ok, Error>;
#[derive(Copy, Clone, Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Base(#[from] odem_rs_core::error::Error),
#[error(transparent)]
Sync(#[from] odem_rs_sync::error::Error),
#[error(transparent)]
Util(#[from] odem_rs_util::error::Error),
}
macro_rules! derive_error_conversion {
(@plain ($($T:tt)*) $E:ident) => {
#[automatically_derived]
impl From<$($T)*::$E> for Error {
#[inline]
fn from(err: $($T)*::$E) -> Self {
$($T)*::Error::from(err).into()
}
}
};
(@generic ($($T:tt)*) $E:ident <$($P:ident)*>) => {
#[automatically_derived]
impl<$($P),*> From<$($T)*::$E<$($P),*>> for Error {
#[inline]
fn from(err: $($T)*::$E<$($P),*>) -> Self {
$($T)*::Error::from(err).into()
}
}
};
(@analyze $T:tt) => {};
(@analyze $T:tt $E:ident <$($P:ident)*> $(, $($R:tt)*)?) => {
derive_error_conversion!(@generic $T $E <$($P),*>);
derive_error_conversion!(@analyze $T $($($R)*)*);
};
(@analyze $T:tt $E:ident $(, $($R:tt)*)?) => {
derive_error_conversion!(@plain $T $E);
derive_error_conversion!(@analyze $T $($($R)*)*);
};
($($T:ident)::+ => $($R:tt)*) => {
derive_error_conversion!(@analyze ($($T)::*) $($R)*);
};
}
derive_error_conversion!(
odem_rs_core::error => Deadlock<T>, NotBorn, NotIdle, NotBusy, NotNext,
NotDone, NotGone, NotInit, NotTerm
);
derive_error_conversion!(
odem_rs_sync::error => SendError<T>, TrySendError<T>, RecvError,
TryRecvError, FacilityOccupied
);
derive_error_conversion!(
odem_rs_util::error => Causality<T>, NegativeWeight<W>, InsufficientSpace<B>
);