1use crate::derivation_path::DerivationPathError;
2
3use std::{
4 fmt::{Debug, Display},
5 hash::Hash,
6};
7
8pub trait Format: Clone + Debug + Display + Send + Sync + 'static + Eq + Ord + Sized + Hash {}
10
11#[derive(Debug, Fail)]
12pub enum FormatError {
13 #[fail(display = "{}: {}", _0, _1)]
14 Crate(&'static str, String),
15
16 #[fail(display = "{}", _0)]
17 DerivationPathError(DerivationPathError),
18
19 #[fail(display = "invalid address prefix: {:?}", _0)]
20 InvalidPrefix(Vec<u8>),
21
22 #[fail(display = "invalid version bytes: {:?}", _0)]
23 InvalidVersionBytes(Vec<u8>),
24
25 #[fail(display = "unsupported derivation path for the format: {}", _0)]
26 UnsupportedDerivationPath(String),
27}
28
29impl From<DerivationPathError> for FormatError {
30 fn from(error: DerivationPathError) -> Self {
31 FormatError::DerivationPathError(error)
32 }
33}
34
35impl From<base58_monero::base58::Error> for FormatError {
36 fn from(error: base58_monero::base58::Error) -> Self {
37 FormatError::Crate("base58_monero", format!("{:?}", error))
38 }
39}