1#[cfg(feature = "alloc")]
7use alloc::boxed::Box;
8
9pub type Result<T> = core::result::Result<T, Error>;
11
12#[derive(Debug, thiserror::Error)]
14pub enum Error {
15 #[error("attempted to read from an empty tape")]
16 EmptyTape,
17 #[error("attempted to write to an empty tape")]
18 WriteToEmptyTape,
19 #[error("invalid operation: {0}")]
20 InvalidOperation(&'static str),
21 #[error(transparent)]
22 CoreError(#[from] rstm_core::Error),
23 #[error(transparent)]
24 StateError(#[from] rstm_state::StateError),
25}
26
27#[cfg(feature = "alloc")]
28impl From<Error> for rstm_core::Error {
29 fn from(err: Error) -> Self {
30 match err {
31 Error::CoreError(e) => e,
32 e => rstm_core::Error::BoxError(Box::new(e)),
33 }
34 }
35}