mirror of
https://github.com/pezkuwichain/merkle-mountain-range.git
synced 2026-06-13 09:31:01 +00:00
refactor: remove failure and f64 for no_std
This commit is contained in:
+19
-5
@@ -1,12 +1,26 @@
|
||||
pub use failure::Fail;
|
||||
pub type Result<T> = core::result::Result<T, Error>;
|
||||
|
||||
#[derive(Fail, Debug, PartialEq, Eq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum Error {
|
||||
#[fail(display = "Get root on an empty MMR")]
|
||||
GetRootOnEmpty,
|
||||
#[fail(display = "Inconsistent store")]
|
||||
InconsistentStore,
|
||||
#[fail(display = "Store error {}", _0)]
|
||||
StoreError(crate::string::String),
|
||||
}
|
||||
|
||||
impl core::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
use Error::*;
|
||||
match self {
|
||||
GetRootOnEmpty => write!(f, "Get root on an empty MMR")?,
|
||||
InconsistentStore => write!(f, "Inconsistent store")?,
|
||||
StoreError(msg) => write!(f, "Store error {}", msg)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
impl ::std::error::Error for Error {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user