diff --git a/Cargo.toml b/Cargo.toml index a865eae..b5815b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,16 +4,17 @@ version = "0.1.0" edition = "2021" [dependencies] +bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] } +sha2 = { version = "0.10.6", default-features = false } -bitvec = {version = "1.0.1", default-features = false, features = ["alloc"]} -sha2 = {version = "0.10.6", default-features = false} +thiserror = { version = "1", optional = true } [dev-dependencies] hex = "0.4.3" [features] default = ["std", "sufficient-memory"] -std = [] +std = ["thiserror"] sufficient-memory = [] [lib] diff --git a/src/error.rs b/src/error.rs index d753835..0ec197d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,10 @@ +#[cfg(feature = "std")] +use std::fmt::{Debug, Display, Formatter, Result}; +#[cfg(feature = "std")] +use thiserror::Error; + #[derive(Debug)] +#[cfg_attr(feature = "std", derive(Error))] pub enum ErrorWordList { DamagedWord, InvalidChecksum, @@ -7,3 +13,11 @@ pub enum ErrorWordList { NoWord, WordsNumber, } + +// TODO: provide actual error descriptions. +#[cfg(feature = "std")] +impl Display for ErrorWordList { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + ::fmt(self, f) + } +}