diff --git a/types/src/lib.rs b/types/src/lib.rs index 0adbd6f6..fe1134ea 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -77,11 +77,9 @@ pub enum NumericError { impl fmt::Display for NumericError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use NumericError::*; - match *self { - Negative{ ref field, value } => write!(f, "expected an unsigned numeric value however the value was negative (field name: {} value: {})", field, value), - Overflow { ref field, value } => write!(f, "a value larger than `u32::MAX` was unexpectedly encountered (field name: {} Value: {})", field, value), + Self::Negative{ ref field, value } => write!(f, "expected an unsigned numeric value however the value was negative (field name: {} value: {})", field, value), + Self::Overflow { ref field, value } => write!(f, "a value larger than `u32::MAX` was unexpectedly encountered (field name: {} Value: {})", field, value), } } } @@ -222,11 +220,11 @@ pub enum ScriptPubkeyError { impl fmt::Display for ScriptPubkeyError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ScriptPubkeyError::*; match *self { - Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - Addresses(ref e) => write_err!(f, "conversion of the `addresses` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Addresses(ref e) => + write_err!(f, "conversion of the `addresses` field failed"; e), } } } @@ -234,11 +232,10 @@ impl fmt::Display for ScriptPubkeyError { #[cfg(feature = "std")] impl std::error::Error for ScriptPubkeyError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ScriptPubkeyError::*; match *self { - Hex(ref e) => Some(e), - Address(ref e) => Some(e), - Addresses(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Addresses(ref e) => Some(e), } } } diff --git a/types/src/psbt/error.rs b/types/src/psbt/error.rs index 6603afc8..9e30f600 100644 --- a/types/src/psbt/error.rs +++ b/types/src/psbt/error.rs @@ -18,12 +18,10 @@ pub enum RawTransactionError { impl fmt::Display for RawTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use RawTransactionError as E; - match *self { - E::Inputs(ref e) => + Self::Inputs(ref e) => write_err!(f, "conversion of one of the transaction inputs failed"; e), - E::Outputs(ref e) => + Self::Outputs(ref e) => write_err!(f, "conversion of one of the transaction outputs failed"; e), } } @@ -32,11 +30,9 @@ impl fmt::Display for RawTransactionError { #[cfg(feature = "std")] impl std::error::Error for RawTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use RawTransactionError as E; - match *self { - E::Inputs(ref e) => Some(e), - E::Outputs(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::Outputs(ref e) => Some(e), } } } @@ -54,13 +50,11 @@ pub enum RawTransactionInputError { impl fmt::Display for RawTransactionInputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use RawTransactionInputError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of the input `txid` field failed"; e), - E::ScriptSig(ref e) => + Self::Txid(ref e) => write_err!(f, "conversion of the input `txid` field failed"; e), + Self::ScriptSig(ref e) => write_err!(f, "conversion of the input `script_sig` field failed"; e), - E::Witness(ref e) => + Self::Witness(ref e) => write_err!(f, "conversion of one of the `witness` hex strings failed"; e), } } @@ -69,12 +63,10 @@ impl fmt::Display for RawTransactionInputError { #[cfg(feature = "std")] impl std::error::Error for RawTransactionInputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use RawTransactionInputError as E; - match *self { - E::Txid(ref e) => Some(e), - E::ScriptSig(ref e) => Some(e), - E::Witness(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::ScriptSig(ref e) => Some(e), + Self::Witness(ref e) => Some(e), } } } @@ -90,11 +82,9 @@ pub enum RawTransactionOutputError { impl fmt::Display for RawTransactionOutputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use RawTransactionOutputError as E; - match *self { - E::Value(ref e) => write_err!(f, "conversion of the output `value` field failed"; e), - E::ScriptPubkey(ref e) => + Self::Value(ref e) => write_err!(f, "conversion of the output `value` field failed"; e), + Self::ScriptPubkey(ref e) => write_err!(f, "conversion of the output `script_pubkey` field failed"; e), } } @@ -103,11 +93,9 @@ impl fmt::Display for RawTransactionOutputError { #[cfg(feature = "std")] impl std::error::Error for RawTransactionOutputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use RawTransactionOutputError as E; - match *self { - E::Value(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), + Self::Value(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), } } } @@ -123,11 +111,9 @@ pub enum WitnessUtxoError { impl fmt::Display for WitnessUtxoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use WitnessUtxoError as E; - match *self { - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::ScriptPubkey(ref e) => + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::ScriptPubkey(ref e) => write_err!(f, "conversion of the `script_pubkey` field failed"; e), } } @@ -136,11 +122,9 @@ impl fmt::Display for WitnessUtxoError { #[cfg(feature = "std")] impl std::error::Error for WitnessUtxoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use WitnessUtxoError as E; - match *self { - E::Amount(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), } } } @@ -156,12 +140,11 @@ pub enum PartialSignatureError { impl fmt::Display for PartialSignatureError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PartialSignatureError as E; - match *self { - E::PublicKey(ref e) => + Self::PublicKey(ref e) => write_err!(f, "partial sigs key-value pair parse pubkey failed"; e), - E::Signature(ref e) => write_err!(f, "partial sigs key-value pair parse sig failed"; e), + Self::Signature(ref e) => + write_err!(f, "partial sigs key-value pair parse sig failed"; e), } } } @@ -169,11 +152,9 @@ impl fmt::Display for PartialSignatureError { #[cfg(feature = "std")] impl std::error::Error for PartialSignatureError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PartialSignatureError as E; - match *self { - E::PublicKey(ref e) => Some(e), - E::Signature(ref e) => Some(e), + Self::PublicKey(ref e) => Some(e), + Self::Signature(ref e) => Some(e), } } } @@ -191,13 +172,11 @@ pub enum Bip32DerivError { impl fmt::Display for Bip32DerivError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use Bip32DerivError as E; - match *self { - E::Pubkey(ref e) => write_err!(f, "conversion of the pubkey failed"; e), - E::MasterFingerprint(ref e) => + Self::Pubkey(ref e) => write_err!(f, "conversion of the pubkey failed"; e), + Self::MasterFingerprint(ref e) => write_err!(f, "conversion of the `master_fingerprint` field failed"; e), - E::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), + Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), } } } @@ -205,12 +184,10 @@ impl fmt::Display for Bip32DerivError { #[cfg(feature = "std")] impl std::error::Error for Bip32DerivError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use Bip32DerivError as E; - match *self { - E::Pubkey(ref e) => Some(e), - E::MasterFingerprint(ref e) => Some(e), - E::Path(ref e) => Some(e), + Self::Pubkey(ref e) => Some(e), + Self::MasterFingerprint(ref e) => Some(e), + Self::Path(ref e) => Some(e), } } } diff --git a/types/src/v17/blockchain/error.rs b/types/src/v17/blockchain/error.rs index f32b8692..1edcd08d 100644 --- a/types/src/v17/blockchain/error.rs +++ b/types/src/v17/blockchain/error.rs @@ -31,17 +31,16 @@ pub enum GetBlockVerboseOneError { impl fmt::Display for GetBlockVerboseOneError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockVerboseOneError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e), - Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), - PreviousBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e), + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::PreviousBlockHash(ref e) => write_err!(f, "conversion of the `previous_block_hash` field failed"; e), - NextBlockHash(ref e) => + Self::NextBlockHash(ref e) => write_err!(f, "conversion of the `next_block_hash` field failed"; e), } } @@ -50,16 +49,14 @@ impl fmt::Display for GetBlockVerboseOneError { #[cfg(feature = "std")] impl std::error::Error for GetBlockVerboseOneError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockVerboseOneError::*; - match *self { - Numeric(ref e) => Some(e), - Hash(ref e) => Some(e), - Tx(ref e) => Some(e), - Bits(ref e) => Some(e), - ChainWork(ref e) => Some(e), - PreviousBlockHash(ref e) => Some(e), - NextBlockHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Bits(ref e) => Some(e), + Self::ChainWork(ref e) => Some(e), + Self::PreviousBlockHash(ref e) => Some(e), + Self::NextBlockHash(ref e) => Some(e), } } } @@ -83,14 +80,13 @@ pub enum GetBlockchainInfoError { impl fmt::Display for GetBlockchainInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockchainInfoError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e), - BestBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e), + Self::BestBlockHash(ref e) => write_err!(f, "conversion of the `best_block_hash` field failed"; e), - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), } } } @@ -98,13 +94,11 @@ impl fmt::Display for GetBlockchainInfoError { #[cfg(feature = "std")] impl std::error::Error for GetBlockchainInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockchainInfoError::*; - match *self { - Numeric(ref e) => Some(e), - Chain(ref e) => Some(e), - BestBlockHash(ref e) => Some(e), - ChainWork(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Chain(ref e) => Some(e), + Self::BestBlockHash(ref e) => Some(e), + Self::ChainWork(ref e) => Some(e), } } } @@ -124,11 +118,10 @@ pub enum GetBlockHeaderError { impl fmt::Display for GetBlockHeaderError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockHeaderError::*; - match *self { - Hex(ref e) => write_err!(f, "conversion of hex data to bytes failed"; e), - Consensus(ref e) => write_err!(f, "consensus decoding of bytes to header failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of hex data to bytes failed"; e), + Self::Consensus(ref e) => + write_err!(f, "consensus decoding of bytes to header failed"; e), } } } @@ -136,11 +129,9 @@ impl fmt::Display for GetBlockHeaderError { #[cfg(feature = "std")] impl std::error::Error for GetBlockHeaderError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockHeaderError::*; - match *self { - Hex(ref e) => Some(e), - Consensus(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Consensus(ref e) => Some(e), } } } @@ -166,17 +157,17 @@ pub enum GetBlockHeaderVerboseError { impl fmt::Display for GetBlockHeaderVerboseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockHeaderVerboseError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - MerkleRoot(ref e) => write_err!(f, "conversion of the `merkle_root` field failed"; e), - Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), - PreviousBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::MerkleRoot(ref e) => + write_err!(f, "conversion of the `merkle_root` field failed"; e), + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::PreviousBlockHash(ref e) => write_err!(f, "conversion of the `previous_block_hash` field failed"; e), - NextBlockHash(ref e) => + Self::NextBlockHash(ref e) => write_err!(f, "conversion of the `next_block_hash` field failed"; e), } } @@ -185,16 +176,14 @@ impl fmt::Display for GetBlockHeaderVerboseError { #[cfg(feature = "std")] impl std::error::Error for GetBlockHeaderVerboseError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockHeaderVerboseError::*; - match *self { - Numeric(ref e) => Some(e), - Hash(ref e) => Some(e), - MerkleRoot(ref e) => Some(e), - Bits(ref e) => Some(e), - ChainWork(ref e) => Some(e), - PreviousBlockHash(ref e) => Some(e), - NextBlockHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + Self::MerkleRoot(ref e) => Some(e), + Self::Bits(ref e) => Some(e), + Self::ChainWork(ref e) => Some(e), + Self::PreviousBlockHash(ref e) => Some(e), + Self::NextBlockHash(ref e) => Some(e), } } } @@ -214,11 +203,10 @@ pub enum GetBlockStatsError { impl fmt::Display for GetBlockStatsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockStatsError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), } } } @@ -226,11 +214,9 @@ impl fmt::Display for GetBlockStatsError { #[cfg(feature = "std")] impl std::error::Error for GetBlockStatsError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockStatsError::*; - match *self { - Numeric(ref e) => Some(e), - BlockHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), } } } @@ -250,11 +236,9 @@ pub enum ChainTipsError { impl fmt::Display for ChainTipsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ChainTipsError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), } } } @@ -262,11 +246,9 @@ impl fmt::Display for ChainTipsError { #[cfg(feature = "std")] impl std::error::Error for ChainTipsError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ChainTipsError::*; - match *self { - Numeric(ref e) => Some(e), - Hash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), } } } @@ -286,11 +268,9 @@ pub enum GetChainTxStatsError { impl fmt::Display for GetChainTxStatsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetChainTxStatsError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - WindowFinalBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::WindowFinalBlockHash(ref e) => write_err!(f, "conversion of the `window_final_block_hash` field failed"; e), } } @@ -299,11 +279,9 @@ impl fmt::Display for GetChainTxStatsError { #[cfg(feature = "std")] impl std::error::Error for GetChainTxStatsError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetChainTxStatsError::*; - match *self { - Numeric(ref e) => Some(e), - WindowFinalBlockHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::WindowFinalBlockHash(ref e) => Some(e), } } } @@ -323,11 +301,9 @@ pub enum MapMempoolEntryError { impl fmt::Display for MapMempoolEntryError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MapMempoolEntryError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of a `txid` failed"; e), - E::MempoolEntry(ref e) => write_err!(f, "conversion of an `MempoolEntry` failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of a `txid` failed"; e), + Self::MempoolEntry(ref e) => write_err!(f, "conversion of an `MempoolEntry` failed"; e), } } } @@ -335,11 +311,9 @@ impl fmt::Display for MapMempoolEntryError { #[cfg(feature = "std")] impl std::error::Error for MapMempoolEntryError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MapMempoolEntryError as E; - match *self { - E::Txid(ref e) => Some(e), - E::MempoolEntry(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::MempoolEntry(ref e) => Some(e), } } } @@ -365,14 +339,12 @@ impl From for MempoolEntryError { impl fmt::Display for MempoolEntryError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolEntryError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), - E::Depends(ref e) => write_err!(f, "conversion of the `depends` field failed"; e), - E::SpentBy(ref e) => write_err!(f, "conversion of the `spent_by` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), + Self::Depends(ref e) => write_err!(f, "conversion of the `depends` field failed"; e), + Self::SpentBy(ref e) => write_err!(f, "conversion of the `spent_by` field failed"; e), } } } @@ -380,14 +352,12 @@ impl fmt::Display for MempoolEntryError { #[cfg(feature = "std")] impl std::error::Error for MempoolEntryError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolEntryError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::Fees(ref e) => Some(e), - E::Depends(ref e) => Some(e), - E::SpentBy(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::Fees(ref e) => Some(e), + Self::Depends(ref e) => Some(e), + Self::SpentBy(ref e) => Some(e), } } } @@ -407,13 +377,12 @@ pub enum MempoolEntryFeesError { impl fmt::Display for MempoolEntryFeesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolEntryFeesError as E; - match *self { - E::Base(ref e) => write_err!(f, "conversion of the `base` field failed"; e), - E::Modified(ref e) => write_err!(f, "conversion of the `modified` field failed"; e), - E::Ancestor(ref e) => write_err!(f, "conversion of the `ancestor` field failed"; e), - E::Descendant(ref e) => write_err!(f, "conversion of the `descendant` field failed"; e), + Self::Base(ref e) => write_err!(f, "conversion of the `base` field failed"; e), + Self::Modified(ref e) => write_err!(f, "conversion of the `modified` field failed"; e), + Self::Ancestor(ref e) => write_err!(f, "conversion of the `ancestor` field failed"; e), + Self::Descendant(ref e) => + write_err!(f, "conversion of the `descendant` field failed"; e), } } } @@ -421,13 +390,11 @@ impl fmt::Display for MempoolEntryFeesError { #[cfg(feature = "std")] impl std::error::Error for MempoolEntryFeesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolEntryFeesError as E; - match *self { - E::Base(ref e) => Some(e), - E::Modified(ref e) => Some(e), - E::Ancestor(ref e) => Some(e), - E::Descendant(ref e) => Some(e), + Self::Base(ref e) => Some(e), + Self::Modified(ref e) => Some(e), + Self::Ancestor(ref e) => Some(e), + Self::Descendant(ref e) => Some(e), } } } @@ -443,11 +410,9 @@ pub enum GetMempoolInfoError { impl fmt::Display for GetMempoolInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetMempoolInfoError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::FeeRate(ref e) => write_err!(f, "fee rate"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::FeeRate(ref e) => write_err!(f, "fee rate"; e), } } } @@ -455,11 +420,9 @@ impl fmt::Display for GetMempoolInfoError { #[cfg(feature = "std")] impl std::error::Error for GetMempoolInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetMempoolInfoError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::FeeRate(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::FeeRate(ref e) => Some(e), } } } @@ -492,15 +455,14 @@ pub enum GetTxOutError { impl fmt::Display for GetTxOutError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTxOutError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - BestBlock(ref e) => write_err!(f, "conversion of the `beast_block` field failed"; e), - Value(ref e) => write_err!(f, "conversion of the `value` field failed"; e), - ScriptBuf(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::BestBlock(ref e) => + write_err!(f, "conversion of the `beast_block` field failed"; e), + Self::Value(ref e) => write_err!(f, "conversion of the `value` field failed"; e), + Self::ScriptBuf(ref e) => write_err!(f, "conversion of the `ScriptPubkey` hex to a `ScriptBuf` failed"; e), - Address(ref e) => + Self::Address(ref e) => write_err!(f, "conversion of the `ScriptPubkey` `address` field failed"; e), } } @@ -509,14 +471,12 @@ impl fmt::Display for GetTxOutError { #[cfg(feature = "std")] impl std::error::Error for GetTxOutError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTxOutError::*; - match *self { - Numeric(ref e) => Some(e), - BestBlock(ref e) => Some(e), - Value(ref e) => Some(e), - ScriptBuf(ref e) => Some(e), - Address(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::BestBlock(ref e) => Some(e), + Self::Value(ref e) => Some(e), + Self::ScriptBuf(ref e) => Some(e), + Self::Address(ref e) => Some(e), } } } @@ -538,12 +498,12 @@ pub enum GetTxOutSetInfoError { impl fmt::Display for GetTxOutSetInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTxOutSetInfoError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - BestBlock(ref e) => write_err!(f, "conversion of the `best_block` field failed"; e), - TotalAmount(ref e) => write_err!(f, "conversion of the `total_amount` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::BestBlock(ref e) => + write_err!(f, "conversion of the `best_block` field failed"; e), + Self::TotalAmount(ref e) => + write_err!(f, "conversion of the `total_amount` field failed"; e), } } } @@ -551,12 +511,10 @@ impl fmt::Display for GetTxOutSetInfoError { #[cfg(feature = "std")] impl std::error::Error for GetTxOutSetInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTxOutSetInfoError::*; - match *self { - Numeric(ref e) => Some(e), - BestBlock(ref e) => Some(e), - TotalAmount(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::BestBlock(ref e) => Some(e), + Self::TotalAmount(ref e) => Some(e), } } } diff --git a/types/src/v17/mining/error.rs b/types/src/v17/mining/error.rs index 8c5a458d..6c929519 100644 --- a/types/src/v17/mining/error.rs +++ b/types/src/v17/mining/error.rs @@ -27,16 +27,14 @@ pub enum GetBlockTemplateError { impl fmt::Display for GetBlockTemplateError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockTemplateError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::PreviousBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::PreviousBlockHash(ref e) => write_err!(f, "conversion of the `previous_block_hash` field failed"; e), - E::Transactions(ref e) => + Self::Transactions(ref e) => write_err!(f, "conversion of the `transactions` field failed"; e), - E::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), - E::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), } } } @@ -44,14 +42,12 @@ impl fmt::Display for GetBlockTemplateError { #[cfg(feature = "std")] impl std::error::Error for GetBlockTemplateError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockTemplateError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::PreviousBlockHash(ref e) => Some(e), - E::Transactions(ref e) => Some(e), - E::Target(ref e) => Some(e), - E::Bits(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::PreviousBlockHash(ref e) => Some(e), + Self::Transactions(ref e) => Some(e), + Self::Target(ref e) => Some(e), + Self::Bits(ref e) => Some(e), } } } @@ -77,14 +73,12 @@ pub enum BlockTemplateTransactionError { impl fmt::Display for BlockTemplateTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use BlockTemplateTransactionError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Data(ref e) => write_err!(f, "conversion of the `data` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Data(ref e) => write_err!(f, "conversion of the `data` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -92,14 +86,12 @@ impl fmt::Display for BlockTemplateTransactionError { #[cfg(feature = "std")] impl std::error::Error for BlockTemplateTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use BlockTemplateTransactionError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Data(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Hash(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Data(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } diff --git a/types/src/v17/network/error.rs b/types/src/v17/network/error.rs index ae7889d4..e8a92061 100644 --- a/types/src/v17/network/error.rs +++ b/types/src/v17/network/error.rs @@ -17,11 +17,9 @@ pub enum GetNetworkInfoError { impl fmt::Display for GetNetworkInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetNetworkInfoError as E; - match *self { - E::RelayFee(ref e) => write_err!(f, "conversion of the `relay_fee` field failed"; e), - E::IncrementalFee(ref e) => + Self::RelayFee(ref e) => write_err!(f, "conversion of the `relay_fee` field failed"; e), + Self::IncrementalFee(ref e) => write_err!(f, "conversion of the `incremental_fee` field failed"; e), } } @@ -30,11 +28,9 @@ impl fmt::Display for GetNetworkInfoError { #[cfg(feature = "std")] impl std::error::Error for GetNetworkInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetNetworkInfoError as E; - match *self { - E::RelayFee(ref e) => Some(e), - E::IncrementalFee(ref e) => Some(e), + Self::RelayFee(ref e) => Some(e), + Self::IncrementalFee(ref e) => Some(e), } } } diff --git a/types/src/v17/raw_transactions/error.rs b/types/src/v17/raw_transactions/error.rs index 5bb469a9..941fd7c9 100644 --- a/types/src/v17/raw_transactions/error.rs +++ b/types/src/v17/raw_transactions/error.rs @@ -28,14 +28,13 @@ pub enum DecodePsbtError { impl fmt::Display for DecodePsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DecodePsbtError as E; - match *self { - E::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), - E::Unknown(ref e) => + Self::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of one the map items in the `unknown` field failed"; e), - E::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), - E::Outputs(ref e) => write_err!(f, "conversion of one of the PSBT outputs failed"; e), + Self::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), + Self::Outputs(ref e) => + write_err!(f, "conversion of one of the PSBT outputs failed"; e), } } } @@ -43,13 +42,11 @@ impl fmt::Display for DecodePsbtError { #[cfg(feature = "std")] impl std::error::Error for DecodePsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DecodePsbtError as E; - match *self { - E::Tx(ref e) => Some(e), - E::Unknown(ref e) => Some(e), - E::Inputs(ref e) => Some(e), - E::Outputs(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::Outputs(ref e) => Some(e), } } } @@ -81,27 +78,25 @@ pub enum PsbtInputError { impl fmt::Display for PsbtInputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtInputError as E; - match *self { - E::NonWitnessUtxo(ref e) => + Self::NonWitnessUtxo(ref e) => write_err!(f, "conversion of the `non_witness_utxo` field failed"; e), - E::WitnessUtxo(ref e) => + Self::WitnessUtxo(ref e) => write_err!(f, "conversion of the `witness_utxo` field failed"; e), - E::PartialSignatures(ref e) => + Self::PartialSignatures(ref e) => write_err!(f, "conversion of the `partial_signatures` field failed"; e), - E::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), - E::RedeemScript(ref e) => + Self::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), - E::Bip32Derivs(ref e) => + Self::Bip32Derivs(ref e) => write_err!(f, "conversion of the `bip32_derivs` field failed"; e), - E::FinalScriptSig(ref e) => + Self::FinalScriptSig(ref e) => write_err!(f, "conversion of the `final_script_sig` field failed"; e), - E::FinalScriptWitness(ref e) => + Self::FinalScriptWitness(ref e) => write_err!(f, "conversion of the `final_script_witness` field failed"; e), - E::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), } } } @@ -109,19 +104,17 @@ impl fmt::Display for PsbtInputError { #[cfg(feature = "std")] impl std::error::Error for PsbtInputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtInputError as E; - match *self { - E::NonWitnessUtxo(ref e) => Some(e), - E::WitnessUtxo(ref e) => Some(e), - E::PartialSignatures(ref e) => Some(e), - E::Sighash(ref e) => Some(e), - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), - E::Bip32Derivs(ref e) => Some(e), - E::FinalScriptSig(ref e) => Some(e), - E::FinalScriptWitness(ref e) => Some(e), - E::Unknown(ref e) => Some(e), + Self::NonWitnessUtxo(ref e) => Some(e), + Self::WitnessUtxo(ref e) => Some(e), + Self::PartialSignatures(ref e) => Some(e), + Self::Sighash(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::FinalScriptSig(ref e) => Some(e), + Self::FinalScriptWitness(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), } } } @@ -141,16 +134,14 @@ pub enum PsbtOutputError { impl fmt::Display for PsbtOutputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtOutputError as E; - match *self { - E::RedeemScript(ref e) => + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), - E::Bip32Derivs(ref e) => + Self::Bip32Derivs(ref e) => write_err!(f, "conversion of the `bip32_derivs` field failed"; e), - E::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), } } } @@ -158,13 +149,11 @@ impl fmt::Display for PsbtOutputError { #[cfg(feature = "std")] impl std::error::Error for PsbtOutputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtOutputError as E; - match *self { - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), - E::Bip32Derivs(ref e) => Some(e), - E::Unknown(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), } } } @@ -182,12 +171,11 @@ pub enum DecodeScriptError { impl fmt::Display for DecodeScriptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DecodeScriptError as E; - match *self { - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Addresses(ref e) => write_err!(f, "conversion of the `addresses` field failed"; e), - E::P2sh(ref e) => write_err!(f, "conversion of the `p2sh` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Addresses(ref e) => + write_err!(f, "conversion of the `addresses` field failed"; e), + Self::P2sh(ref e) => write_err!(f, "conversion of the `p2sh` field failed"; e), } } } @@ -195,12 +183,10 @@ impl fmt::Display for DecodeScriptError { #[cfg(feature = "std")] impl std::error::Error for DecodeScriptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DecodeScriptError as E; - match *self { - E::Hex(ref e) => Some(e), - E::Addresses(ref e) => Some(e), - E::P2sh(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Addresses(ref e) => Some(e), + Self::P2sh(ref e) => Some(e), } } } @@ -216,11 +202,9 @@ pub enum FinalizePsbtError { impl fmt::Display for FinalizePsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use FinalizePsbtError as E; - match *self { - E::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), } } } @@ -228,11 +212,9 @@ impl fmt::Display for FinalizePsbtError { #[cfg(feature = "std")] impl std::error::Error for FinalizePsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use FinalizePsbtError as E; - match *self { - E::Psbt(ref e) => Some(e), - E::Hex(ref e) => Some(e), + Self::Psbt(ref e) => Some(e), + Self::Hex(ref e) => Some(e), } } } @@ -248,11 +230,9 @@ pub enum FundRawTransactionError { impl fmt::Display for FundRawTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use FundRawTransactionError as E; - match *self { - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -260,11 +240,9 @@ impl fmt::Display for FundRawTransactionError { #[cfg(feature = "std")] impl std::error::Error for FundRawTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use FundRawTransactionError as E; - match *self { - E::Hex(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } @@ -282,14 +260,13 @@ pub enum GetRawTransactionVerboseError { impl fmt::Display for GetRawTransactionVerboseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetRawTransactionVerboseError as E; - match *self { - E::Inputs(ref e) => + Self::Inputs(ref e) => write_err!(f, "conversion of one of the transaction inputs failed"; e), - E::Outputs(ref e) => + Self::Outputs(ref e) => write_err!(f, "conversion of one of the transaction outputs failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), } } } @@ -297,12 +274,10 @@ impl fmt::Display for GetRawTransactionVerboseError { #[cfg(feature = "std")] impl std::error::Error for GetRawTransactionVerboseError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetRawTransactionVerboseError as E; - match *self { - E::Inputs(ref e) => Some(e), - E::Outputs(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::Outputs(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), } } } @@ -318,11 +293,9 @@ pub enum SignRawTransactionError { impl fmt::Display for SignRawTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SignRawTransactionError as E; - match *self { - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Errors(ref e) => write_err!(f, "conversion of the `errors` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Errors(ref e) => write_err!(f, "conversion of the `errors` field failed"; e), } } } @@ -330,11 +303,9 @@ impl fmt::Display for SignRawTransactionError { #[cfg(feature = "std")] impl std::error::Error for SignRawTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SignRawTransactionError as E; - match *self { - E::Hex(ref e) => Some(e), - E::Errors(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Errors(ref e) => Some(e), } } } @@ -350,11 +321,10 @@ pub enum SignFailError { impl fmt::Display for SignFailError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SignFailError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::ScriptSig(ref e) => write_err!(f, "conversion of the `script_sig` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::ScriptSig(ref e) => + write_err!(f, "conversion of the `script_sig` field failed"; e), } } } @@ -362,11 +332,9 @@ impl fmt::Display for SignFailError { #[cfg(feature = "std")] impl std::error::Error for SignFailError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SignFailError as E; - match *self { - E::Txid(ref e) => Some(e), - E::ScriptSig(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::ScriptSig(ref e) => Some(e), } } } diff --git a/types/src/v17/util/error.rs b/types/src/v17/util/error.rs index 6b70a787..f195b99b 100644 --- a/types/src/v17/util/error.rs +++ b/types/src/v17/util/error.rs @@ -16,11 +16,9 @@ pub enum CreateMultisigError { impl fmt::Display for CreateMultisigError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use CreateMultisigError as E; - match *self { - E::Address(ref e) => write!(f, "conversion of the `address` field failed: {}", e), - E::RedeemScript(ref e) => + Self::Address(ref e) => write!(f, "conversion of the `address` field failed: {}", e), + Self::RedeemScript(ref e) => write!(f, "conversion of the `redeem_script` field failed: {}", e), } } @@ -29,11 +27,9 @@ impl fmt::Display for CreateMultisigError { #[cfg(feature = "std")] impl std::error::Error for CreateMultisigError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use CreateMultisigError as E; - match *self { - E::Address(ref e) => Some(e), - E::RedeemScript(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), } } } @@ -57,21 +53,19 @@ pub enum ValidateAddressError { impl fmt::Display for ValidateAddressError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ValidateAddressError as E; - match *self { - E::Address(ref e) => write!(f, "conversion of the `address` field failed: {}", e), - E::ScriptPubkey(ref e) => + Self::Address(ref e) => write!(f, "conversion of the `address` field failed: {}", e), + Self::ScriptPubkey(ref e) => write!(f, "conversion of the `script_pubkey` field failed: {}", e), - E::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), - E::WitnessVersion(ref e) => + Self::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), + Self::WitnessVersion(ref e) => write!(f, "conversion of the `witness_version` field failed: {}", e), - E::WitnessProgramBytes(ref e) => write!( + Self::WitnessProgramBytes(ref e) => write!( f, "conversion of the `witness_program` field hex string to bytes failed: {}", e ), - E::WitnessProgram(ref e) => + Self::WitnessProgram(ref e) => write!(f, "conversion of the `witness_program` field failed: {}", e), } } @@ -80,15 +74,13 @@ impl fmt::Display for ValidateAddressError { #[cfg(feature = "std")] impl std::error::Error for ValidateAddressError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ValidateAddressError as E; - match *self { - E::Address(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), - E::WitnessVersionValue(_) => None, - E::WitnessVersion(ref e) => Some(e), - E::WitnessProgramBytes(ref e) => Some(e), - E::WitnessProgram(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), + Self::WitnessVersionValue(_) => None, + Self::WitnessVersion(ref e) => Some(e), + Self::WitnessProgramBytes(ref e) => Some(e), + Self::WitnessProgram(ref e) => Some(e), } } } diff --git a/types/src/v17/wallet/error.rs b/types/src/v17/wallet/error.rs index b04a8a62..37e2d061 100644 --- a/types/src/v17/wallet/error.rs +++ b/types/src/v17/wallet/error.rs @@ -21,11 +21,9 @@ pub enum AddMultisigAddressError { impl fmt::Display for AddMultisigAddressError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use AddMultisigAddressError::*; - match *self { - Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - RedeemScript(ref e) => + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), } } @@ -34,11 +32,9 @@ impl fmt::Display for AddMultisigAddressError { #[cfg(feature = "std")] impl std::error::Error for AddMultisigAddressError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use AddMultisigAddressError::*; - match *self { - Address(ref e) => Some(e), - RedeemScript(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), } } } @@ -56,13 +52,11 @@ pub enum BumpFeeError { impl fmt::Display for BumpFeeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use BumpFeeError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::OriginalFee(ref e) => + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::OriginalFee(ref e) => write_err!(f, "conversion of the `original_fee` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -70,12 +64,10 @@ impl fmt::Display for BumpFeeError { #[cfg(feature = "std")] impl std::error::Error for BumpFeeError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use BumpFeeError as E; - match *self { - E::Txid(ref e) => Some(e), - E::OriginalFee(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::OriginalFee(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } @@ -113,26 +105,26 @@ pub enum GetAddressInfoError { impl fmt::Display for GetAddressInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetAddressInfoError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::ScriptPubkey(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::ScriptPubkey(ref e) => write_err!(f, "conversion of the `script_pubkey` field failed"; e), - E::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), - E::WitnessVersion(ref e) => + Self::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), + Self::WitnessVersion(ref e) => write_err!(f, "conversion of the `witness_version` field failed"; e), - E::WitnessProgramBytes(ref e) => + Self::WitnessProgramBytes(ref e) => write_err!(f, "conversion of the `witness_program` field hex string to bytes failed"; e), - E::WitnessProgram(ref e) => + Self::WitnessProgram(ref e) => write_err!(f, "conversion of the `witness_program` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), - E::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` failed"; e), - E::Embedded(ref e) => write_err!(f, "conversion of the `embedded` field failed"; e), - E::HdKeyPath(ref e) => write_err!(f, "conversion of the `hd_key_path` field failed"; e), - E::HdSeedId(ref e) => write_err!(f, "conversion of the `hd_seed_id` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` failed"; e), + Self::Embedded(ref e) => write_err!(f, "conversion of the `embedded` field failed"; e), + Self::HdKeyPath(ref e) => + write_err!(f, "conversion of the `hd_key_path` field failed"; e), + Self::HdSeedId(ref e) => + write_err!(f, "conversion of the `hd_seed_id` field failed"; e), } } } @@ -140,22 +132,20 @@ impl fmt::Display for GetAddressInfoError { #[cfg(feature = "std")] impl std::error::Error for GetAddressInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetAddressInfoError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), - E::WitnessVersionValue(_) => None, - E::WitnessVersion(ref e) => Some(e), - E::WitnessProgramBytes(ref e) => Some(e), - E::WitnessProgram(ref e) => Some(e), - E::Hex(ref e) => Some(e), - E::Pubkeys(ref e) => Some(e), - E::Pubkey(ref e) => Some(e), - E::Embedded(ref e) => Some(e), - E::HdKeyPath(ref e) => Some(e), - E::HdSeedId(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), + Self::WitnessVersionValue(_) => None, + Self::WitnessVersion(ref e) => Some(e), + Self::WitnessProgramBytes(ref e) => Some(e), + Self::WitnessProgram(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Pubkeys(ref e) => Some(e), + Self::Pubkey(ref e) => Some(e), + Self::Embedded(ref e) => Some(e), + Self::HdKeyPath(ref e) => Some(e), + Self::HdSeedId(ref e) => Some(e), } } } @@ -191,23 +181,21 @@ pub enum GetAddressInfoEmbeddedError { impl fmt::Display for GetAddressInfoEmbeddedError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetAddressInfoEmbeddedError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::ScriptPubkey(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::ScriptPubkey(ref e) => write_err!(f, "conversion of the `script_pubkey` field failed"; e), - E::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), - E::WitnessVersion(ref e) => + Self::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), + Self::WitnessVersion(ref e) => write_err!(f, "conversion of the `witness_version` field failed"; e), - E::WitnessProgramBytes(ref e) => + Self::WitnessProgramBytes(ref e) => write_err!(f, "conversion of the `witness_program` field hex string to bytes failed"; e), - E::WitnessProgram(ref e) => + Self::WitnessProgram(ref e) => write_err!(f, "conversion of the `witness_program` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), - E::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` failed"; e), } } } @@ -215,19 +203,17 @@ impl fmt::Display for GetAddressInfoEmbeddedError { #[cfg(feature = "std")] impl std::error::Error for GetAddressInfoEmbeddedError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetAddressInfoEmbeddedError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), - E::WitnessVersionValue(_) => None, - E::WitnessVersion(ref e) => Some(e), - E::WitnessProgramBytes(ref e) => Some(e), - E::WitnessProgram(ref e) => Some(e), - E::Hex(ref e) => Some(e), - E::Pubkeys(ref e) => Some(e), - E::Pubkey(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), + Self::WitnessVersionValue(_) => None, + Self::WitnessVersion(ref e) => Some(e), + Self::WitnessProgramBytes(ref e) => Some(e), + Self::WitnessProgram(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Pubkeys(ref e) => Some(e), + Self::Pubkey(ref e) => Some(e), } } } @@ -259,18 +245,17 @@ pub enum GetTransactionError { impl fmt::Display for GetTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), + Self::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), } } } @@ -278,17 +263,15 @@ impl fmt::Display for GetTransactionError { #[cfg(feature = "std")] impl std::error::Error for GetTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::Tx(ref e) => Some(e), - E::Details(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Details(ref e) => Some(e), } } } @@ -310,12 +293,10 @@ pub enum GetTransactionDetailError { impl fmt::Display for GetTransactionDetailError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTransactionDetailError::*; - match *self { - Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -323,12 +304,10 @@ impl fmt::Display for GetTransactionDetailError { #[cfg(feature = "std")] impl std::error::Error for GetTransactionDetailError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTransactionDetailError as E; - match *self { - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } @@ -352,17 +331,17 @@ pub enum GetWalletInfoError { impl fmt::Display for GetWalletInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetWalletInfoError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Balance(ref e) => write_err!(f, "conversion of the `balance` field failed"; e), - UnconfirmedBalance(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Balance(ref e) => write_err!(f, "conversion of the `balance` field failed"; e), + Self::UnconfirmedBalance(ref e) => write_err!(f, "conversion of the `unconfirmed_balance` field failed"; e), - ImmatureBalance(ref e) => + Self::ImmatureBalance(ref e) => write_err!(f, "conversion of the `immature_balance` field failed"; e), - PayTxFee(ref e) => write_err!(f, "conversion of the `pay_tx_fee` field failed"; e), - HdSeedId(ref e) => write_err!(f, "conversion of the `hd_seed_id` field failed"; e), + Self::PayTxFee(ref e) => + write_err!(f, "conversion of the `pay_tx_fee` field failed"; e), + Self::HdSeedId(ref e) => + write_err!(f, "conversion of the `hd_seed_id` field failed"; e), } } } @@ -370,15 +349,13 @@ impl fmt::Display for GetWalletInfoError { #[cfg(feature = "std")] impl std::error::Error for GetWalletInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetWalletInfoError::*; - match *self { - Numeric(ref e) => Some(e), - Balance(ref e) => Some(e), - UnconfirmedBalance(ref e) => Some(e), - ImmatureBalance(ref e) => Some(e), - PayTxFee(ref e) => Some(e), - HdSeedId(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Balance(ref e) => Some(e), + Self::UnconfirmedBalance(ref e) => Some(e), + Self::ImmatureBalance(ref e) => Some(e), + Self::PayTxFee(ref e) => Some(e), + Self::HdSeedId(ref e) => Some(e), } } } @@ -398,11 +375,9 @@ pub enum ListAddressGroupingsError { impl fmt::Display for ListAddressGroupingsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListAddressGroupingsError::*; - match *self { - Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), } } } @@ -410,11 +385,9 @@ impl fmt::Display for ListAddressGroupingsError { #[cfg(feature = "std")] impl std::error::Error for ListAddressGroupingsError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListAddressGroupingsError::*; - match *self { - Address(ref e) => Some(e), - Amount(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), } } } @@ -430,11 +403,9 @@ pub enum ListLockUnspentItemError { impl fmt::Display for ListLockUnspentItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListLockUnspentItemError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), } } } @@ -442,11 +413,9 @@ impl fmt::Display for ListLockUnspentItemError { #[cfg(feature = "std")] impl std::error::Error for ListLockUnspentItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListLockUnspentItemError::*; - match *self { - Numeric(ref e) => Some(e), - Txid(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), } } } @@ -468,12 +437,10 @@ pub enum ListReceivedByAddressError { impl fmt::Display for ListReceivedByAddressError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListReceivedByAddressError::*; - match *self { - Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - Txids(index, ref e) => + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Txids(index, ref e) => write_err!(f, "conversion of the txid at index {} in the `txids` field failed", index; e), } } @@ -482,12 +449,10 @@ impl fmt::Display for ListReceivedByAddressError { #[cfg(feature = "std")] impl std::error::Error for ListReceivedByAddressError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListReceivedByAddressError::*; - match *self { - Address(ref e) => Some(e), - Amount(ref e) => Some(e), - Txids(_, ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Txids(_, ref e) => Some(e), } } } @@ -505,13 +470,12 @@ pub enum ListSinceBlockError { impl fmt::Display for ListSinceBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockError::*; - match *self { - Transactions(ref e) => + Self::Transactions(ref e) => write_err!(f, "conversion of the `transactions` field failed"; e), - Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), - LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + Self::Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + Self::LastBlock(ref e) => + write_err!(f, "conversion of the `last_block` field failed"; e), } } } @@ -519,12 +483,10 @@ impl fmt::Display for ListSinceBlockError { #[cfg(feature = "std")] impl std::error::Error for ListSinceBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockError::*; - match *self { - Transactions(ref e) => Some(e), - Removed(ref e) => Some(e), - LastBlock(ref e) => Some(e), + Self::Transactions(ref e) => Some(e), + Self::Removed(ref e) => Some(e), + Self::LastBlock(ref e) => Some(e), } } } @@ -548,15 +510,14 @@ pub enum TransactionItemError { impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TransactionItemError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), } } } @@ -564,15 +525,13 @@ impl fmt::Display for TransactionItemError { #[cfg(feature = "std")] impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TransactionItemError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), } } } @@ -602,18 +561,16 @@ pub enum ListUnspentItemError { impl fmt::Display for ListUnspentItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListUnspentItemError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::ScriptPubkey(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::ScriptPubkey(ref e) => write_err!(f, "conversion of the `script_pubkey` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::RedeemScript(ref e) => + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -621,16 +578,14 @@ impl fmt::Display for ListUnspentItemError { #[cfg(feature = "std")] impl std::error::Error for ListUnspentItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListUnspentItemError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::RedeemScript(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } @@ -652,12 +607,10 @@ pub enum WalletCreateFundedPsbtError { impl fmt::Display for WalletCreateFundedPsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use WalletCreateFundedPsbtError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -665,12 +618,10 @@ impl fmt::Display for WalletCreateFundedPsbtError { #[cfg(feature = "std")] impl std::error::Error for WalletCreateFundedPsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use WalletCreateFundedPsbtError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Psbt(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Psbt(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } diff --git a/types/src/v18/raw_transactions/error.rs b/types/src/v18/raw_transactions/error.rs index 740614a7..8d1deaec 100644 --- a/types/src/v18/raw_transactions/error.rs +++ b/types/src/v18/raw_transactions/error.rs @@ -20,13 +20,11 @@ pub enum AnalyzePsbtError { impl fmt::Display for AnalyzePsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use AnalyzePsbtError as E; - match *self { - E::Inputs(ref e) => write_err!(f, "conversion of one of the `inputs` failed"; e), - E::EstimatedFeeRate(ref e) => + Self::Inputs(ref e) => write_err!(f, "conversion of one of the `inputs` failed"; e), + Self::EstimatedFeeRate(ref e) => write_err!(f, "conversion of the `estimated_fee_rate` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -34,12 +32,10 @@ impl fmt::Display for AnalyzePsbtError { #[cfg(feature = "std")] impl std::error::Error for AnalyzePsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use AnalyzePsbtError as E; - match *self { - E::Inputs(ref e) => Some(e), - E::EstimatedFeeRate(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::EstimatedFeeRate(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } @@ -59,14 +55,13 @@ pub enum AnalyzePsbtInputMissingError { impl fmt::Display for AnalyzePsbtInputMissingError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use AnalyzePsbtInputMissingError as E; - match *self { - E::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), - E::Signatures(ref e) => write_err!(f, "conversion of the `signatures` field failed"; e), - E::RedeemScript(ref e) => + Self::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), + Self::Signatures(ref e) => + write_err!(f, "conversion of the `signatures` field failed"; e), + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), } } @@ -75,13 +70,11 @@ impl fmt::Display for AnalyzePsbtInputMissingError { #[cfg(feature = "std")] impl std::error::Error for AnalyzePsbtInputMissingError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use AnalyzePsbtInputMissingError as E; - match *self { - E::Pubkeys(ref e) => Some(e), - E::Signatures(ref e) => Some(e), - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), + Self::Pubkeys(ref e) => Some(e), + Self::Signatures(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), } } } diff --git a/types/src/v18/wallet/error.rs b/types/src/v18/wallet/error.rs index 6a1c7054..b1f20078 100644 --- a/types/src/v18/wallet/error.rs +++ b/types/src/v18/wallet/error.rs @@ -44,27 +44,27 @@ pub enum GetAddressInfoError { impl fmt::Display for GetAddressInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetAddressInfoError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::ScriptPubkey(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::ScriptPubkey(ref e) => write_err!(f, "conversion of the `script_pubkey` field failed"; e), - E::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), - E::WitnessVersion(ref e) => + Self::WitnessVersionValue(v) => write!(f, "invalid witness version number: {}", v), + Self::WitnessVersion(ref e) => write_err!(f, "conversion of the `witness_version` field failed"; e), - E::WitnessProgramBytes(ref e) => + Self::WitnessProgramBytes(ref e) => write_err!(f, "conversion of the `witness_program` field hex string to bytes failed"; e), - E::WitnessProgram(ref e) => + Self::WitnessProgram(ref e) => write_err!(f, "conversion of the `witness_program` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), - E::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` failed"; e), - E::Embedded(ref e) => write_err!(f, "conversion of the `embedded` field failed"; e), - E::HdKeyPath(ref e) => write_err!(f, "conversion of the `hd_key_path` field failed"; e), - E::HdSeedId(ref e) => write_err!(f, "conversion of the `hd_seed_id` field failed"; e), - E::HdMasterFingerprint(ref e) => + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Pubkeys(ref e) => write_err!(f, "conversion of the `pubkeys` field failed"; e), + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` failed"; e), + Self::Embedded(ref e) => write_err!(f, "conversion of the `embedded` field failed"; e), + Self::HdKeyPath(ref e) => + write_err!(f, "conversion of the `hd_key_path` field failed"; e), + Self::HdSeedId(ref e) => + write_err!(f, "conversion of the `hd_seed_id` field failed"; e), + Self::HdMasterFingerprint(ref e) => write_err!(f, "conversion of the `hd_master_fingerprint` field failed"; e), } } @@ -73,23 +73,21 @@ impl fmt::Display for GetAddressInfoError { #[cfg(feature = "std")] impl std::error::Error for GetAddressInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetAddressInfoError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::ScriptPubkey(ref e) => Some(e), - E::WitnessVersionValue(_) => None, - E::WitnessVersion(ref e) => Some(e), - E::WitnessProgramBytes(ref e) => Some(e), - E::WitnessProgram(ref e) => Some(e), - E::Hex(ref e) => Some(e), - E::Pubkeys(ref e) => Some(e), - E::Pubkey(ref e) => Some(e), - E::Embedded(ref e) => Some(e), - E::HdKeyPath(ref e) => Some(e), - E::HdSeedId(ref e) => Some(e), - E::HdMasterFingerprint(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::ScriptPubkey(ref e) => Some(e), + Self::WitnessVersionValue(_) => None, + Self::WitnessVersion(ref e) => Some(e), + Self::WitnessProgramBytes(ref e) => Some(e), + Self::WitnessProgram(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Pubkeys(ref e) => Some(e), + Self::Pubkey(ref e) => Some(e), + Self::Embedded(ref e) => Some(e), + Self::HdKeyPath(ref e) => Some(e), + Self::HdSeedId(ref e) => Some(e), + Self::HdMasterFingerprint(ref e) => Some(e), } } } @@ -109,11 +107,9 @@ pub enum ListReceivedByLabelError { impl fmt::Display for ListReceivedByLabelError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListReceivedByLabelError::*; - match *self { - Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -121,11 +117,9 @@ impl fmt::Display for ListReceivedByLabelError { #[cfg(feature = "std")] impl std::error::Error for ListReceivedByLabelError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListReceivedByLabelError::*; - match *self { - Amount(ref e) => Some(e), - Numeric(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), } } } diff --git a/types/src/v19/blockchain/error.rs b/types/src/v19/blockchain/error.rs index c60a687c..8d8dff0b 100644 --- a/types/src/v19/blockchain/error.rs +++ b/types/src/v19/blockchain/error.rs @@ -24,15 +24,14 @@ pub enum GetBlockchainInfoError { impl fmt::Display for GetBlockchainInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockchainInfoError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e), - BestBlockHash(ref e) => { + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e), + Self::BestBlockHash(ref e) => { write_err!(f, "conversion of the `best_block_hash` field failed"; e) } - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), } } } @@ -40,13 +39,11 @@ impl fmt::Display for GetBlockchainInfoError { #[cfg(feature = "std")] impl std::error::Error for GetBlockchainInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockchainInfoError::*; - match *self { - Numeric(ref e) => Some(e), - Chain(ref e) => Some(e), - BestBlockHash(ref e) => Some(e), - ChainWork(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Chain(ref e) => Some(e), + Self::BestBlockHash(ref e) => Some(e), + Self::ChainWork(ref e) => Some(e), } } } @@ -66,11 +63,9 @@ pub enum GetBlockFilterError { impl fmt::Display for GetBlockFilterError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockFilterError as E; - match *self { - E::Filter(ref e) => write_err!(f, "conversion of the `filter` field failed"; e), - E::Header(ref e) => write_err!(f, "conversion of the `header` field failed"; e), + Self::Filter(ref e) => write_err!(f, "conversion of the `filter` field failed"; e), + Self::Header(ref e) => write_err!(f, "conversion of the `header` field failed"; e), } } } @@ -78,11 +73,9 @@ impl fmt::Display for GetBlockFilterError { #[cfg(feature = "std")] impl std::error::Error for GetBlockFilterError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockFilterError as E; - match *self { - E::Filter(ref e) => Some(e), - E::Header(ref e) => Some(e), + Self::Filter(ref e) => Some(e), + Self::Header(ref e) => Some(e), } } } @@ -98,11 +91,9 @@ pub enum MapMempoolEntryError { impl fmt::Display for MapMempoolEntryError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MapMempoolEntryError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of a `txid` failed"; e), - E::MempoolEntry(ref e) => write_err!(f, "conversion of an `MempoolEntry` failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of a `txid` failed"; e), + Self::MempoolEntry(ref e) => write_err!(f, "conversion of an `MempoolEntry` failed"; e), } } } @@ -110,11 +101,9 @@ impl fmt::Display for MapMempoolEntryError { #[cfg(feature = "std")] impl std::error::Error for MapMempoolEntryError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MapMempoolEntryError as E; - match *self { - E::Txid(ref e) => Some(e), - E::MempoolEntry(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::MempoolEntry(ref e) => Some(e), } } } @@ -140,14 +129,12 @@ impl From for MempoolEntryError { impl fmt::Display for MempoolEntryError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolEntryError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), - E::Depends(ref e) => write_err!(f, "conversion of the `depends` field failed"; e), - E::SpentBy(ref e) => write_err!(f, "conversion of the `spent_by` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), + Self::Depends(ref e) => write_err!(f, "conversion of the `depends` field failed"; e), + Self::SpentBy(ref e) => write_err!(f, "conversion of the `spent_by` field failed"; e), } } } @@ -155,14 +142,12 @@ impl fmt::Display for MempoolEntryError { #[cfg(feature = "std")] impl std::error::Error for MempoolEntryError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolEntryError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::Fees(ref e) => Some(e), - E::Depends(ref e) => Some(e), - E::SpentBy(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::Fees(ref e) => Some(e), + Self::Depends(ref e) => Some(e), + Self::SpentBy(ref e) => Some(e), } } } @@ -182,13 +167,13 @@ pub enum MempoolEntryFeesError { impl fmt::Display for MempoolEntryFeesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolEntryFeesError as E; - match *self { - E::Base(ref e) => write_err!(f, "conversion of the `base` field failed"; e), - E::Modified(ref e) => write_err!(f, "conversion of the `modified` field failed"; e), - E::MempoolEntry(ref e) => write_err!(f, "conversion of the `ancestor` field failed"; e), - E::Descendant(ref e) => write_err!(f, "conversion of the `descendant` field failed"; e), + Self::Base(ref e) => write_err!(f, "conversion of the `base` field failed"; e), + Self::Modified(ref e) => write_err!(f, "conversion of the `modified` field failed"; e), + Self::MempoolEntry(ref e) => + write_err!(f, "conversion of the `ancestor` field failed"; e), + Self::Descendant(ref e) => + write_err!(f, "conversion of the `descendant` field failed"; e), } } } @@ -196,13 +181,11 @@ impl fmt::Display for MempoolEntryFeesError { #[cfg(feature = "std")] impl std::error::Error for MempoolEntryFeesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolEntryFeesError as E; - match *self { - E::Base(ref e) => Some(e), - E::Modified(ref e) => Some(e), - E::MempoolEntry(ref e) => Some(e), - E::Descendant(ref e) => Some(e), + Self::Base(ref e) => Some(e), + Self::Modified(ref e) => Some(e), + Self::MempoolEntry(ref e) => Some(e), + Self::Descendant(ref e) => Some(e), } } } diff --git a/types/src/v19/wallet/error.rs b/types/src/v19/wallet/error.rs index ba21e98b..461a08f2 100644 --- a/types/src/v19/wallet/error.rs +++ b/types/src/v19/wallet/error.rs @@ -17,11 +17,10 @@ pub enum GetBalancesError { impl fmt::Display for GetBalancesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBalancesError as E; - match *self { - E::Mine(ref e) => write_err!(f, "conversion of the `mine` field failed"; e), - E::WatchOnly(ref e) => write_err!(f, "conversion of the `watchonly` field failed"; e), + Self::Mine(ref e) => write_err!(f, "conversion of the `mine` field failed"; e), + Self::WatchOnly(ref e) => + write_err!(f, "conversion of the `watchonly` field failed"; e), } } } @@ -29,11 +28,9 @@ impl fmt::Display for GetBalancesError { #[cfg(feature = "std")] impl std::error::Error for GetBalancesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBalancesError as E; - match *self { - E::Mine(ref e) => Some(e), - E::WatchOnly(ref e) => Some(e), + Self::Mine(ref e) => Some(e), + Self::WatchOnly(ref e) => Some(e), } } } diff --git a/types/src/v20/wallet/error.rs b/types/src/v20/wallet/error.rs index bda57914..d11a6559 100644 --- a/types/src/v20/wallet/error.rs +++ b/types/src/v20/wallet/error.rs @@ -23,13 +23,12 @@ pub enum ListSinceBlockError { impl fmt::Display for ListSinceBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockError::*; - match *self { - Transactions(ref e) => + Self::Transactions(ref e) => write_err!(f, "conversion of the `transactions` field failed"; e), - Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), - LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + Self::Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + Self::LastBlock(ref e) => + write_err!(f, "conversion of the `last_block` field failed"; e), } } } @@ -37,12 +36,10 @@ impl fmt::Display for ListSinceBlockError { #[cfg(feature = "std")] impl std::error::Error for ListSinceBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockError::*; - match *self { - Transactions(ref e) => Some(e), - Removed(ref e) => Some(e), - LastBlock(ref e) => Some(e), + Self::Transactions(ref e) => Some(e), + Self::Removed(ref e) => Some(e), + Self::LastBlock(ref e) => Some(e), } } } @@ -72,16 +69,15 @@ pub enum TransactionItemError { impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TransactionItemError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of an item in the `wallet_conflicts` list failed"; e), } } @@ -90,16 +86,14 @@ impl fmt::Display for TransactionItemError { #[cfg(feature = "std")] impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TransactionItemError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), } } } diff --git a/types/src/v21/raw_transactions/error.rs b/types/src/v21/raw_transactions/error.rs index 9f4debf9..7f80cc63 100644 --- a/types/src/v21/raw_transactions/error.rs +++ b/types/src/v21/raw_transactions/error.rs @@ -17,10 +17,8 @@ pub enum TestMempoolAcceptError { impl fmt::Display for TestMempoolAcceptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TestMempoolAcceptError as E; - match *self { - E::MempoolAcceptance(ref e) => + Self::MempoolAcceptance(ref e) => write_err!(f, "conversion of one of the mempool acceptance results failed"; e), } } @@ -29,10 +27,8 @@ impl fmt::Display for TestMempoolAcceptError { #[cfg(feature = "std")] impl std::error::Error for TestMempoolAcceptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TestMempoolAcceptError as E; - match *self { - E::MempoolAcceptance(ref e) => Some(e), + Self::MempoolAcceptance(ref e) => Some(e), } } } @@ -54,12 +50,10 @@ pub enum MempoolAcceptanceError { impl fmt::Display for MempoolAcceptanceError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolAcceptanceError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "conversion of a numeric field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Base(ref e) => write_err!(f, "conversion of the `base` fee field failed"; e), + Self::Numeric(ref e) => write_err!(f, "conversion of a numeric field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Base(ref e) => write_err!(f, "conversion of the `base` fee field failed"; e), } } } @@ -67,12 +61,10 @@ impl fmt::Display for MempoolAcceptanceError { #[cfg(feature = "std")] impl std::error::Error for MempoolAcceptanceError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolAcceptanceError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Base(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Base(ref e) => Some(e), } } } diff --git a/types/src/v21/wallet/error.rs b/types/src/v21/wallet/error.rs index 576151c7..c50de8ed 100644 --- a/types/src/v21/wallet/error.rs +++ b/types/src/v21/wallet/error.rs @@ -23,13 +23,11 @@ pub enum PsbtBumpFeeError { impl fmt::Display for PsbtBumpFeeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtBumpFeeError as E; - match *self { - E::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), - E::OriginalFee(ref e) => + Self::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), + Self::OriginalFee(ref e) => write_err!(f, "conversion of the `original_fee` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), } } } @@ -37,12 +35,10 @@ impl fmt::Display for PsbtBumpFeeError { #[cfg(feature = "std")] impl std::error::Error for PsbtBumpFeeError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtBumpFeeError as E; - match *self { - E::Psbt(ref e) => Some(e), - E::OriginalFee(ref e) => Some(e), - E::Fee(ref e) => Some(e), + Self::Psbt(ref e) => Some(e), + Self::OriginalFee(ref e) => Some(e), + Self::Fee(ref e) => Some(e), } } } @@ -62,13 +58,11 @@ pub enum SendError { impl fmt::Display for SendError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SendError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), - E::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -76,13 +70,11 @@ impl fmt::Display for SendError { #[cfg(feature = "std")] impl std::error::Error for SendError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SendError as E; - match *self { - E::Txid(ref e) => Some(e), - E::Hex(ref e) => Some(e), - E::Psbt(ref e) => Some(e), - E::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Psbt(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), } } } diff --git a/types/src/v22/raw_transactions/error.rs b/types/src/v22/raw_transactions/error.rs index 6c8622e5..ef795695 100644 --- a/types/src/v22/raw_transactions/error.rs +++ b/types/src/v22/raw_transactions/error.rs @@ -23,13 +23,12 @@ pub enum DecodeScriptError { impl fmt::Display for DecodeScriptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DecodeScriptError as E; - match *self { - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Addresses(ref e) => write_err!(f, "conversion of the `addresses` field failed"; e), - E::P2sh(ref e) => write_err!(f, "conversion of the `p2sh` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Addresses(ref e) => + write_err!(f, "conversion of the `addresses` field failed"; e), + Self::P2sh(ref e) => write_err!(f, "conversion of the `p2sh` field failed"; e), } } } @@ -37,13 +36,11 @@ impl fmt::Display for DecodeScriptError { #[cfg(feature = "std")] impl std::error::Error for DecodeScriptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DecodeScriptError as E; - match *self { - E::Hex(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Addresses(ref e) => Some(e), - E::P2sh(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Addresses(ref e) => Some(e), + Self::P2sh(ref e) => Some(e), } } } @@ -57,10 +54,8 @@ pub enum TestMempoolAcceptError { impl fmt::Display for TestMempoolAcceptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TestMempoolAcceptError as E; - match *self { - E::MempoolAcceptance(ref e) => + Self::MempoolAcceptance(ref e) => write_err!(f, "conversion of one of the mempool acceptance results failed"; e), } } @@ -69,10 +64,8 @@ impl fmt::Display for TestMempoolAcceptError { #[cfg(feature = "std")] impl std::error::Error for TestMempoolAcceptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TestMempoolAcceptError as E; - match *self { - E::MempoolAcceptance(ref e) => Some(e), + Self::MempoolAcceptance(ref e) => Some(e), } } } @@ -96,13 +89,11 @@ pub enum MempoolAcceptanceError { impl fmt::Display for MempoolAcceptanceError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolAcceptanceError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "conversion of a numeric field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::Base(ref e) => write_err!(f, "conversion of the `base` fee field failed"; e), + Self::Numeric(ref e) => write_err!(f, "conversion of a numeric field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::Base(ref e) => write_err!(f, "conversion of the `base` fee field failed"; e), } } } @@ -110,13 +101,11 @@ impl fmt::Display for MempoolAcceptanceError { #[cfg(feature = "std")] impl std::error::Error for MempoolAcceptanceError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolAcceptanceError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::Base(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::Base(ref e) => Some(e), } } } diff --git a/types/src/v23/blockchain/error.rs b/types/src/v23/blockchain/error.rs index ab799d15..00abf937 100644 --- a/types/src/v23/blockchain/error.rs +++ b/types/src/v23/blockchain/error.rs @@ -17,11 +17,9 @@ pub enum GetDeploymentInfoError { impl fmt::Display for GetDeploymentInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetDeploymentInfoError as E; - match *self { - E::BlockHash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - E::Deployment(ref e) => + Self::BlockHash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Deployment(ref e) => write_err!(f, "conversion of the `deployments` field failed"; e), } } @@ -30,11 +28,9 @@ impl fmt::Display for GetDeploymentInfoError { #[cfg(feature = "std")] impl std::error::Error for GetDeploymentInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetDeploymentInfoError as E; - match *self { - E::BlockHash(ref e) => Some(e), - E::Deployment(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Deployment(ref e) => Some(e), } } } diff --git a/types/src/v23/raw_transactions/error.rs b/types/src/v23/raw_transactions/error.rs index ab9ad9ef..d9eec75f 100644 --- a/types/src/v23/raw_transactions/error.rs +++ b/types/src/v23/raw_transactions/error.rs @@ -26,18 +26,17 @@ pub enum DecodePsbtError { impl fmt::Display for DecodePsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DecodePsbtError as E; - match *self { - E::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), - E::GlobalXpubs(ref e) => + Self::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), + Self::GlobalXpubs(ref e) => write_err!(f, "conversion of one the map items in the `global_xbubs` field failed"; e), - E::Proprietary(ref e) => + Self::Proprietary(ref e) => write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), - E::Unknown(ref e) => + Self::Unknown(ref e) => write_err!(f, "conversion of one the map items in the `unknown` field failed"; e), - E::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), - E::Outputs(ref e) => write_err!(f, "conversion of one of the PSBT outputs failed"; e), + Self::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), + Self::Outputs(ref e) => + write_err!(f, "conversion of one of the PSBT outputs failed"; e), } } } @@ -45,15 +44,13 @@ impl fmt::Display for DecodePsbtError { #[cfg(feature = "std")] impl std::error::Error for DecodePsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DecodePsbtError as E; - match *self { - E::Tx(ref e) => Some(e), - E::GlobalXpubs(ref e) => Some(e), - E::Proprietary(ref e) => Some(e), - E::Unknown(ref e) => Some(e), - E::Inputs(ref e) => Some(e), - E::Outputs(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::GlobalXpubs(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::Outputs(ref e) => Some(e), } } } @@ -71,13 +68,11 @@ pub enum GlobalXpubError { impl fmt::Display for GlobalXpubError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GlobalXpubError as E; - match *self { - E::Xpub(ref e) => write_err!(f, "conversion of the xpub failed"; e), - E::MasterFingerprint(ref e) => + Self::Xpub(ref e) => write_err!(f, "conversion of the xpub failed"; e), + Self::MasterFingerprint(ref e) => write_err!(f, "conversion of the `master_fingerprint` field failed"; e), - E::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), + Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), } } } @@ -85,12 +80,10 @@ impl fmt::Display for GlobalXpubError { #[cfg(feature = "std")] impl std::error::Error for GlobalXpubError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GlobalXpubError as E; - match *self { - E::Xpub(ref e) => Some(e), - E::MasterFingerprint(ref e) => Some(e), - E::Path(ref e) => Some(e), + Self::Xpub(ref e) => Some(e), + Self::MasterFingerprint(ref e) => Some(e), + Self::Path(ref e) => Some(e), } } } @@ -140,41 +133,39 @@ pub enum PsbtInputError { impl fmt::Display for PsbtInputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtInputError as E; - match *self { - E::NonWitnessUtxo(ref e) => + Self::NonWitnessUtxo(ref e) => write_err!(f, "conversion of the `non_witness_utxo` field failed"; e), - E::WitnessUtxo(ref e) => + Self::WitnessUtxo(ref e) => write_err!(f, "conversion of the `witness_utxo` field failed"; e), - E::PartialSignatures(ref e) => + Self::PartialSignatures(ref e) => write_err!(f, "conversion of the `partial_signatures` field failed"; e), - E::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), - E::RedeemScript(ref e) => + Self::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), - E::Bip32Derivs(ref e) => + Self::Bip32Derivs(ref e) => write_err!(f, "conversion of the `bip32_derivs` field failed"; e), - E::FinalScriptSig(ref e) => + Self::FinalScriptSig(ref e) => write_err!(f, "conversion of the `final_script_sig` field failed"; e), - E::FinalScriptWitness(ref e) => + Self::FinalScriptWitness(ref e) => write_err!(f, "conversion of the `final_script_witness` field failed"; e), - E::Ripemd160(ref e) => write_err!(f, "conversion of the `ripemd160` hash failed"; e), - E::Ripemd160Preimage(ref e) => + Self::Ripemd160(ref e) => write_err!(f, "conversion of the `ripemd160` hash failed"; e), + Self::Ripemd160Preimage(ref e) => write_err!(f, "conversion of the `ripemd160` preimage failed"; e), - E::Sha256(ref e) => write_err!(f, "conversion of the `sha256` hash failed"; e), - E::Sha256Preimage(ref e) => + Self::Sha256(ref e) => write_err!(f, "conversion of the `sha256` hash failed"; e), + Self::Sha256Preimage(ref e) => write_err!(f, "conversion of the `sha256` preimage failed"; e), - E::Hash160(ref e) => write_err!(f, "conversion of the `hash160` hash failed"; e), - E::Hash160Preimage(ref e) => + Self::Hash160(ref e) => write_err!(f, "conversion of the `hash160` hash failed"; e), + Self::Hash160Preimage(ref e) => write_err!(f, "conversion of the `hash160` preimage failed"; e), - E::Hash256(ref e) => write_err!(f, "conversion of the `hash256` hash failed"; e), - E::Hash256Preimage(ref e) => + Self::Hash256(ref e) => write_err!(f, "conversion of the `hash256` hash failed"; e), + Self::Hash256Preimage(ref e) => write_err!(f, "conversion of the `hash256` preimage failed"; e), - E::Proprietary(ref e) => + Self::Proprietary(ref e) => write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), - E::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), } } } @@ -182,28 +173,26 @@ impl fmt::Display for PsbtInputError { #[cfg(feature = "std")] impl std::error::Error for PsbtInputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtInputError as E; - match *self { - E::NonWitnessUtxo(ref e) => Some(e), - E::WitnessUtxo(ref e) => Some(e), - E::PartialSignatures(ref e) => Some(e), - E::Sighash(ref e) => Some(e), - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), - E::Bip32Derivs(ref e) => Some(e), - E::FinalScriptSig(ref e) => Some(e), - E::FinalScriptWitness(ref e) => Some(e), - E::Ripemd160(ref e) => Some(e), - E::Ripemd160Preimage(ref e) => Some(e), - E::Sha256(ref e) => Some(e), - E::Sha256Preimage(ref e) => Some(e), - E::Hash160(ref e) => Some(e), - E::Hash160Preimage(ref e) => Some(e), - E::Hash256(ref e) => Some(e), - E::Hash256Preimage(ref e) => Some(e), - E::Proprietary(ref e) => Some(e), - E::Unknown(ref e) => Some(e), + Self::NonWitnessUtxo(ref e) => Some(e), + Self::WitnessUtxo(ref e) => Some(e), + Self::PartialSignatures(ref e) => Some(e), + Self::Sighash(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::FinalScriptSig(ref e) => Some(e), + Self::FinalScriptWitness(ref e) => Some(e), + Self::Ripemd160(ref e) => Some(e), + Self::Ripemd160Preimage(ref e) => Some(e), + Self::Sha256(ref e) => Some(e), + Self::Sha256Preimage(ref e) => Some(e), + Self::Hash160(ref e) => Some(e), + Self::Hash160Preimage(ref e) => Some(e), + Self::Hash256(ref e) => Some(e), + Self::Hash256Preimage(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), } } } @@ -225,18 +214,16 @@ pub enum PsbtOutputError { impl fmt::Display for PsbtOutputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtOutputError as E; - match *self { - E::RedeemScript(ref e) => + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), - E::Bip32Derivs(ref e) => + Self::Bip32Derivs(ref e) => write_err!(f, "conversion of the `bip32_derivs` field failed"; e), - E::Proprietary(ref e) => + Self::Proprietary(ref e) => write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), - E::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), } } } @@ -244,14 +231,12 @@ impl fmt::Display for PsbtOutputError { #[cfg(feature = "std")] impl std::error::Error for PsbtOutputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtOutputError as E; - match *self { - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), - E::Bip32Derivs(ref e) => Some(e), - E::Proprietary(ref e) => Some(e), - E::Unknown(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), } } } @@ -271,13 +256,12 @@ pub enum DecodeScriptError { impl fmt::Display for DecodeScriptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DecodeScriptError as E; - match *self { - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Addresses(ref e) => write_err!(f, "conversion of the `addresses` field failed"; e), - E::P2sh(ref e) => write_err!(f, "conversion of the `p2sh` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Addresses(ref e) => + write_err!(f, "conversion of the `addresses` field failed"; e), + Self::P2sh(ref e) => write_err!(f, "conversion of the `p2sh` field failed"; e), } } } @@ -285,13 +269,11 @@ impl fmt::Display for DecodeScriptError { #[cfg(feature = "std")] impl std::error::Error for DecodeScriptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DecodeScriptError as E; - match *self { - E::Hex(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Addresses(ref e) => Some(e), - E::P2sh(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Addresses(ref e) => Some(e), + Self::P2sh(ref e) => Some(e), } } } diff --git a/types/src/v23/wallet/error.rs b/types/src/v23/wallet/error.rs index 583f0a89..6deb275a 100644 --- a/types/src/v23/wallet/error.rs +++ b/types/src/v23/wallet/error.rs @@ -48,12 +48,12 @@ pub enum ListSinceBlockError { impl fmt::Display for ListSinceBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockError::*; match *self { - Transactions(ref e) => + Self::Transactions(ref e) => write_err!(f, "conversion of the `transactions` field failed"; e), - Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), - LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + Self::Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + Self::LastBlock(ref e) => + write_err!(f, "conversion of the `last_block` field failed"; e), } } } @@ -61,11 +61,10 @@ impl fmt::Display for ListSinceBlockError { #[cfg(feature = "std")] impl std::error::Error for ListSinceBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockError::*; match *self { - Transactions(ref e) => Some(e), - Removed(ref e) => Some(e), - LastBlock(ref e) => Some(e), + Self::Transactions(ref e) => Some(e), + Self::Removed(ref e) => Some(e), + Self::LastBlock(ref e) => Some(e), } } } @@ -95,19 +94,19 @@ pub enum TransactionItemError { impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TransactionItemError as E; match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::ReplacedByTxid(ref e) => + Self::ReplacedByTxid(ref e) => write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), - E::ReplacesTxid(ref e) => + Self::ReplacesTxid(ref e) => write_err!(f, "conversion of the `replaces_txid` field failed"; e), } } @@ -116,17 +115,16 @@ impl fmt::Display for TransactionItemError { #[cfg(feature = "std")] impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TransactionItemError as E; match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::ReplacedByTxid(ref e) => Some(e), - E::ReplacesTxid(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::ReplacedByTxid(ref e) => Some(e), + Self::ReplacesTxid(ref e) => Some(e), } } } @@ -137,22 +135,21 @@ impl From for TransactionItemError { impl fmt::Display for GetTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::ReplacedByTxid(ref e) => + Self::ReplacedByTxid(ref e) => write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), - E::ReplacesTxid(ref e) => + Self::ReplacesTxid(ref e) => write_err!(f, "conversion of the `replaces_txid` field failed"; e), - E::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), + Self::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), } } } @@ -160,19 +157,17 @@ impl fmt::Display for GetTransactionError { #[cfg(feature = "std")] impl std::error::Error for GetTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::ReplacedByTxid(ref e) => Some(e), - E::ReplacesTxid(ref e) => Some(e), - E::Tx(ref e) => Some(e), - E::Details(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::ReplacedByTxid(ref e) => Some(e), + Self::ReplacesTxid(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Details(ref e) => Some(e), } } } diff --git a/types/src/v24/blockchain/error.rs b/types/src/v24/blockchain/error.rs index 9036b7b3..5326b142 100644 --- a/types/src/v24/blockchain/error.rs +++ b/types/src/v24/blockchain/error.rs @@ -16,10 +16,9 @@ pub enum GetTxSpendingPrevoutError { impl fmt::Display for GetTxSpendingPrevoutError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTxSpendingPrevoutError as E; match *self { - E::Txid(ref e) => write_err!(f, "conversion of the `outpoint` field failed"; e), - E::SpendingTxid(ref e) => + Self::Txid(ref e) => write_err!(f, "conversion of the `outpoint` field failed"; e), + Self::SpendingTxid(ref e) => write_err!(f, "conversion of the `spending_txid` field failed"; e), } } @@ -28,10 +27,9 @@ impl fmt::Display for GetTxSpendingPrevoutError { #[cfg(feature = "std")] impl std::error::Error for GetTxSpendingPrevoutError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTxSpendingPrevoutError as E; match *self { - E::Txid(ref e) => Some(e), - E::SpendingTxid(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::SpendingTxid(ref e) => Some(e), } } } diff --git a/types/src/v24/raw_transactions/error.rs b/types/src/v24/raw_transactions/error.rs index 458f29fc..0b2352bc 100644 --- a/types/src/v24/raw_transactions/error.rs +++ b/types/src/v24/raw_transactions/error.rs @@ -27,18 +27,17 @@ pub enum DecodePsbtError { impl fmt::Display for DecodePsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DecodePsbtError as E; - match *self { - E::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), - E::GlobalXpubs(ref e) => + Self::Tx(ref e) => write_err!(f, "conversion of raw transaction data field failed"; e), + Self::GlobalXpubs(ref e) => write_err!(f, "conversion of one the map items in the `global_xbubs` field failed"; e), - E::Proprietary(ref e) => + Self::Proprietary(ref e) => write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), - E::Unknown(ref e) => + Self::Unknown(ref e) => write_err!(f, "conversion of one the map items in the `unknown` field failed"; e), - E::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), - E::Outputs(ref e) => write_err!(f, "conversion of one of the PSBT outputs failed"; e), + Self::Inputs(ref e) => write_err!(f, "conversion of one of the PSBT inputs failed"; e), + Self::Outputs(ref e) => + write_err!(f, "conversion of one of the PSBT outputs failed"; e), } } } @@ -46,15 +45,13 @@ impl fmt::Display for DecodePsbtError { #[cfg(feature = "std")] impl std::error::Error for DecodePsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DecodePsbtError as E; - match *self { - E::Tx(ref e) => Some(e), - E::GlobalXpubs(ref e) => Some(e), - E::Proprietary(ref e) => Some(e), - E::Unknown(ref e) => Some(e), - E::Inputs(ref e) => Some(e), - E::Outputs(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::GlobalXpubs(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), + Self::Inputs(ref e) => Some(e), + Self::Outputs(ref e) => Some(e), } } } @@ -72,13 +69,11 @@ pub enum GlobalXpubError { impl fmt::Display for GlobalXpubError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GlobalXpubError as E; - match *self { - E::Xpub(ref e) => write_err!(f, "conversion of the xpub failed"; e), - E::MasterFingerprint(ref e) => + Self::Xpub(ref e) => write_err!(f, "conversion of the xpub failed"; e), + Self::MasterFingerprint(ref e) => write_err!(f, "conversion of the `master_fingerprint` field failed"; e), - E::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), + Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), } } } @@ -86,12 +81,10 @@ impl fmt::Display for GlobalXpubError { #[cfg(feature = "std")] impl std::error::Error for GlobalXpubError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GlobalXpubError as E; - match *self { - E::Xpub(ref e) => Some(e), - E::MasterFingerprint(ref e) => Some(e), - E::Path(ref e) => Some(e), + Self::Xpub(ref e) => Some(e), + Self::MasterFingerprint(ref e) => Some(e), + Self::Path(ref e) => Some(e), } } } @@ -153,53 +146,51 @@ pub enum PsbtInputError { impl fmt::Display for PsbtInputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtInputError as E; - match *self { - E::NonWitnessUtxo(ref e) => + Self::NonWitnessUtxo(ref e) => write_err!(f, "conversion of the `non_witness_utxo` field failed"; e), - E::WitnessUtxo(ref e) => + Self::WitnessUtxo(ref e) => write_err!(f, "conversion of the `witness_utxo` field failed"; e), - E::PartialSignatures(ref e) => + Self::PartialSignatures(ref e) => write_err!(f, "conversion of the `partial_signatures` field failed"; e), - E::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), - E::RedeemScript(ref e) => + Self::Sighash(ref e) => write_err!(f, "conversion of the `sighash` field failed"; e), + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), - E::Bip32Derivs(ref e) => + Self::Bip32Derivs(ref e) => write_err!(f, "conversion of the `bip32_derivs` field failed"; e), - E::FinalScriptSig(ref e) => + Self::FinalScriptSig(ref e) => write_err!(f, "conversion of the `final_script_sig` field failed"; e), - E::FinalScriptWitness(ref e) => + Self::FinalScriptWitness(ref e) => write_err!(f, "conversion of the `final_script_witness` field failed"; e), - E::Ripemd160(ref e) => write_err!(f, "conversion of the `ripemd160` hash failed"; e), - E::Ripemd160Preimage(ref e) => + Self::Ripemd160(ref e) => write_err!(f, "conversion of the `ripemd160` hash failed"; e), + Self::Ripemd160Preimage(ref e) => write_err!(f, "conversion of the `ripemd160` preimage failed"; e), - E::Sha256(ref e) => write_err!(f, "conversion of the `sha256` hash failed"; e), - E::Sha256Preimage(ref e) => + Self::Sha256(ref e) => write_err!(f, "conversion of the `sha256` hash failed"; e), + Self::Sha256Preimage(ref e) => write_err!(f, "conversion of the `sha256` preimage failed"; e), - E::Hash160(ref e) => write_err!(f, "conversion of the `hash160` hash failed"; e), - E::Hash160Preimage(ref e) => + Self::Hash160(ref e) => write_err!(f, "conversion of the `hash160` hash failed"; e), + Self::Hash160Preimage(ref e) => write_err!(f, "conversion of the `hash160` preimage failed"; e), - E::Hash256(ref e) => write_err!(f, "conversion of the `hash256` hash failed"; e), - E::Hash256Preimage(ref e) => + Self::Hash256(ref e) => write_err!(f, "conversion of the `hash256` hash failed"; e), + Self::Hash256Preimage(ref e) => write_err!(f, "conversion of the `hash256` preimage failed"; e), - E::TaprootKeyPathSig(ref e) => + Self::TaprootKeyPathSig(ref e) => write_err!(f, "conversion of the `taproot_key_path_sig` field failed"; e), - E::TaprootScriptPathSigs(ref e) => + Self::TaprootScriptPathSigs(ref e) => write_err!(f, "conversion of the `taproot_script_path_sigs` field failed"; e), - E::TaprootScripts(ref e) => + Self::TaprootScripts(ref e) => write_err!(f, "conversion of the `taproot_scripts` field failed"; e), - E::TaprootBip32Derivs(ref e) => + Self::TaprootBip32Derivs(ref e) => write_err!(f, "conversion of the `taproot_bip32_derivs` field failed"; e), - E::TaprootInternalKey(ref e) => + Self::TaprootInternalKey(ref e) => write_err!(f, "conversion of the `taproot_internal_key` field failed"; e), - E::TaprootMerkleRoot(ref e) => + Self::TaprootMerkleRoot(ref e) => write_err!(f, "conversion of the `taproot_merkle_root` field failed"; e), - E::Proprietary(ref e) => + Self::Proprietary(ref e) => write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), - E::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), } } } @@ -207,34 +198,32 @@ impl fmt::Display for PsbtInputError { #[cfg(feature = "std")] impl std::error::Error for PsbtInputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtInputError as E; - match *self { - E::NonWitnessUtxo(ref e) => Some(e), - E::WitnessUtxo(ref e) => Some(e), - E::PartialSignatures(ref e) => Some(e), - E::Sighash(ref e) => Some(e), - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), - E::Bip32Derivs(ref e) => Some(e), - E::FinalScriptSig(ref e) => Some(e), - E::FinalScriptWitness(ref e) => Some(e), - E::Ripemd160(ref e) => Some(e), - E::Ripemd160Preimage(ref e) => Some(e), - E::Sha256(ref e) => Some(e), - E::Sha256Preimage(ref e) => Some(e), - E::Hash160(ref e) => Some(e), - E::Hash160Preimage(ref e) => Some(e), - E::Hash256(ref e) => Some(e), - E::Hash256Preimage(ref e) => Some(e), - E::TaprootKeyPathSig(ref e) => Some(e), - E::TaprootScriptPathSigs(ref e) => Some(e), - E::TaprootScripts(ref e) => Some(e), - E::TaprootBip32Derivs(ref e) => Some(e), - E::TaprootInternalKey(ref e) => Some(e), - E::TaprootMerkleRoot(ref e) => Some(e), - E::Proprietary(ref e) => Some(e), - E::Unknown(ref e) => Some(e), + Self::NonWitnessUtxo(ref e) => Some(e), + Self::WitnessUtxo(ref e) => Some(e), + Self::PartialSignatures(ref e) => Some(e), + Self::Sighash(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::FinalScriptSig(ref e) => Some(e), + Self::FinalScriptWitness(ref e) => Some(e), + Self::Ripemd160(ref e) => Some(e), + Self::Ripemd160Preimage(ref e) => Some(e), + Self::Sha256(ref e) => Some(e), + Self::Sha256Preimage(ref e) => Some(e), + Self::Hash160(ref e) => Some(e), + Self::Hash160Preimage(ref e) => Some(e), + Self::Hash256(ref e) => Some(e), + Self::Hash256Preimage(ref e) => Some(e), + Self::TaprootKeyPathSig(ref e) => Some(e), + Self::TaprootScriptPathSigs(ref e) => Some(e), + Self::TaprootScripts(ref e) => Some(e), + Self::TaprootBip32Derivs(ref e) => Some(e), + Self::TaprootInternalKey(ref e) => Some(e), + Self::TaprootMerkleRoot(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), } } } @@ -262,24 +251,22 @@ pub enum PsbtOutputError { impl fmt::Display for PsbtOutputError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use PsbtOutputError as E; - match *self { - E::RedeemScript(ref e) => + Self::RedeemScript(ref e) => write_err!(f, "conversion of the `redeem_script` field failed"; e), - E::WitnessScript(ref e) => + Self::WitnessScript(ref e) => write_err!(f, "conversion of the `witness_script` field failed"; e), - E::Bip32Derivs(ref e) => + Self::Bip32Derivs(ref e) => write_err!(f, "conversion of the `bip32_derivs` field failed"; e), - E::TaprootInternalKey(ref e) => + Self::TaprootInternalKey(ref e) => write_err!(f, "conversion of the `taproot_internal_key` field failed"; e), - E::TaprootTree(ref e) => + Self::TaprootTree(ref e) => write_err!(f, "conversion of the `taproot_tree` field failed"; e), - E::TaprootBip32Derivs(ref e) => + Self::TaprootBip32Derivs(ref e) => write_err!(f, "conversion of the `taproot_bip32_derivs` field failed"; e), - E::Proprietary(ref e) => + Self::Proprietary(ref e) => write_err!(f, "conversion of one the map items in the `proprietray` field failed"; e), - E::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), + Self::Unknown(ref e) => write_err!(f, "conversion of the `unknown` field failed"; e), } } } @@ -287,17 +274,15 @@ impl fmt::Display for PsbtOutputError { #[cfg(feature = "std")] impl std::error::Error for PsbtOutputError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use PsbtOutputError as E; - match *self { - E::RedeemScript(ref e) => Some(e), - E::WitnessScript(ref e) => Some(e), - E::Bip32Derivs(ref e) => Some(e), - E::TaprootInternalKey(ref e) => Some(e), - E::TaprootTree(ref e) => Some(e), - E::TaprootBip32Derivs(ref e) => Some(e), - E::Proprietary(ref e) => Some(e), - E::Unknown(ref e) => Some(e), + Self::RedeemScript(ref e) => Some(e), + Self::WitnessScript(ref e) => Some(e), + Self::Bip32Derivs(ref e) => Some(e), + Self::TaprootInternalKey(ref e) => Some(e), + Self::TaprootTree(ref e) => Some(e), + Self::TaprootBip32Derivs(ref e) => Some(e), + Self::Proprietary(ref e) => Some(e), + Self::Unknown(ref e) => Some(e), } } } @@ -315,12 +300,10 @@ pub enum TaprootScriptPathSigError { impl fmt::Display for TaprootScriptPathSigError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TaprootScriptPathSigError as E; - match *self { - E::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` field failed"; e), - E::LeafHash(ref e) => write_err!(f, "conversion of the `leaf_hash` field failed"; e), - E::Sig(ref e) => write_err!(f, "conversion of the `sig` field failed"; e), + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` field failed"; e), + Self::LeafHash(ref e) => write_err!(f, "conversion of the `leaf_hash` field failed"; e), + Self::Sig(ref e) => write_err!(f, "conversion of the `sig` field failed"; e), } } } @@ -328,12 +311,10 @@ impl fmt::Display for TaprootScriptPathSigError { #[cfg(feature = "std")] impl std::error::Error for TaprootScriptPathSigError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TaprootScriptPathSigError as E; - match *self { - E::Pubkey(ref e) => Some(e), - E::LeafHash(ref e) => Some(e), - E::Sig(ref e) => Some(e), + Self::Pubkey(ref e) => Some(e), + Self::LeafHash(ref e) => Some(e), + Self::Sig(ref e) => Some(e), } } } @@ -351,12 +332,10 @@ pub enum TaprootScriptError { impl fmt::Display for TaprootScriptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TaprootScriptError as E; - match *self { - E::Script(ref e) => write_err!(f, "conversion of the `script` field failed"; e), - E::LeafVer(ref e) => write_err!(f, "conversion of the `leaf_ver` field failed"; e), - E::ControlBlocks(ref e) => + Self::Script(ref e) => write_err!(f, "conversion of the `script` field failed"; e), + Self::LeafVer(ref e) => write_err!(f, "conversion of the `leaf_ver` field failed"; e), + Self::ControlBlocks(ref e) => write_err!(f, "conversion of the `control_blocks` field failed"; e), } } @@ -365,12 +344,10 @@ impl fmt::Display for TaprootScriptError { #[cfg(feature = "std")] impl std::error::Error for TaprootScriptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TaprootScriptError as E; - match *self { - E::Script(ref e) => Some(e), - E::LeafVer(ref e) => Some(e), - E::ControlBlocks(ref e) => Some(e), + Self::Script(ref e) => Some(e), + Self::LeafVer(ref e) => Some(e), + Self::ControlBlocks(ref e) => Some(e), } } } @@ -390,14 +367,12 @@ pub enum ControlBlocksError { impl fmt::Display for ControlBlocksError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ControlBlocksError as E; - match *self { - E::Missing => write!(f, "no control block returned by Core for this script"), - E::Multiple(n) => + Self::Missing => write!(f, "no control block returned by Core for this script"), + Self::Multiple(n) => write!(f, "multiple control blocks returned by Core for this script: {}", n), - E::Parse(ref e) => write_err!(f, "failed to parse control block hex"; e), - E::Decode(ref e) => write_err!(f, "failed to decode control block from bytes"; e), + Self::Parse(ref e) => write_err!(f, "failed to parse control block hex"; e), + Self::Decode(ref e) => write_err!(f, "failed to decode control block from bytes"; e), } } } @@ -405,13 +380,11 @@ impl fmt::Display for ControlBlocksError { #[cfg(feature = "std")] impl std::error::Error for ControlBlocksError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ControlBlocksError as E; - match *self { - E::Missing => None, - E::Multiple(_) => None, - E::Parse(ref e) => Some(e), - E::Decode(ref e) => Some(e), + Self::Missing => None, + Self::Multiple(_) => None, + Self::Parse(ref e) => Some(e), + Self::Decode(ref e) => Some(e), } } } @@ -431,14 +404,12 @@ pub enum TaprootBip32DerivsError { impl fmt::Display for TaprootBip32DerivsError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TaprootBip32DerivsError as E; - match *self { - E::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` field failed"; e), - E::MasterFingerprint(ref e) => + Self::Pubkey(ref e) => write_err!(f, "conversion of the `pubkey` field failed"; e), + Self::MasterFingerprint(ref e) => write_err!(f, "conversion of the `master_fingerprint` field failed"; e), - E::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), - E::LeafHashes(ref e) => + Self::Path(ref e) => write_err!(f, "conversion of the `path` field failed"; e), + Self::LeafHashes(ref e) => write_err!(f, "conversion of the `leaf_hashes` field failed"; e), } } @@ -447,13 +418,11 @@ impl fmt::Display for TaprootBip32DerivsError { #[cfg(feature = "std")] impl std::error::Error for TaprootBip32DerivsError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TaprootBip32DerivsError as E; - match *self { - E::Pubkey(ref e) => Some(e), - E::MasterFingerprint(ref e) => Some(e), - E::Path(ref e) => Some(e), - E::LeafHashes(ref e) => Some(e), + Self::Pubkey(ref e) => Some(e), + Self::MasterFingerprint(ref e) => Some(e), + Self::Path(ref e) => Some(e), + Self::LeafHashes(ref e) => Some(e), } } } @@ -473,13 +442,11 @@ pub enum TaprootLeafError { impl fmt::Display for TaprootLeafError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TaprootLeafError as E; - match *self { - E::LeafVer(ref e) => write_err!(f, "conversion of the `leaf_ver` field failed"; e), - E::Script(ref e) => write_err!(f, "conversion of the `script` field failed"; e), - E::TaprootBuilder(ref e) => write_err!(f, "failed to add leaf to builder"; e), - E::IncompleteBuilder(ref e) => + Self::LeafVer(ref e) => write_err!(f, "conversion of the `leaf_ver` field failed"; e), + Self::Script(ref e) => write_err!(f, "conversion of the `script` field failed"; e), + Self::TaprootBuilder(ref e) => write_err!(f, "failed to add leaf to builder"; e), + Self::IncompleteBuilder(ref e) => write_err!(f, "failed to convert builder into a tap tree"; e), } } @@ -488,13 +455,11 @@ impl fmt::Display for TaprootLeafError { #[cfg(feature = "std")] impl std::error::Error for TaprootLeafError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TaprootLeafError as E; - match *self { - E::Script(ref e) => Some(e), - E::LeafVer(ref e) => Some(e), - E::TaprootBuilder(ref e) => Some(e), - E::IncompleteBuilder(ref e) => Some(e), + Self::Script(ref e) => Some(e), + Self::LeafVer(ref e) => Some(e), + Self::TaprootBuilder(ref e) => Some(e), + Self::IncompleteBuilder(ref e) => Some(e), } } } diff --git a/types/src/v24/wallet/error.rs b/types/src/v24/wallet/error.rs index f3821387..3b1f8ee0 100644 --- a/types/src/v24/wallet/error.rs +++ b/types/src/v24/wallet/error.rs @@ -42,25 +42,24 @@ pub enum GetTransactionError { impl fmt::Display for GetTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::ReplacedByTxid(ref e) => + Self::ReplacedByTxid(ref e) => write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), - E::ReplacesTxid(ref e) => + Self::ReplacesTxid(ref e) => write_err!(f, "conversion of the `replaces_txid` field failed"; e), - E::MempoolConflicts(ref e) => + Self::MempoolConflicts(ref e) => write_err!(f, "conversion of the `mempool_conflicts` field failed"; e), - E::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), + Self::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), } } } @@ -68,21 +67,19 @@ impl fmt::Display for GetTransactionError { #[cfg(feature = "std")] impl std::error::Error for GetTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::ReplacedByTxid(ref e) => Some(e), - E::ReplacesTxid(ref e) => Some(e), - E::MempoolConflicts(ref e) => Some(e), - E::Tx(ref e) => Some(e), - E::Details(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::ReplacedByTxid(ref e) => Some(e), + Self::ReplacesTxid(ref e) => Some(e), + Self::MempoolConflicts(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Details(ref e) => Some(e), } } } @@ -104,12 +101,12 @@ pub enum ListSinceBlockError { impl fmt::Display for ListSinceBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockError::*; match *self { - Transactions(ref e) => + Self::Transactions(ref e) => write_err!(f, "conversion of the `transactions` field failed"; e), - Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), - LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + Self::Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + Self::LastBlock(ref e) => + write_err!(f, "conversion of the `last_block` field failed"; e), } } } @@ -117,11 +114,10 @@ impl fmt::Display for ListSinceBlockError { #[cfg(feature = "std")] impl std::error::Error for ListSinceBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockError::*; match *self { - Transactions(ref e) => Some(e), - Removed(ref e) => Some(e), - LastBlock(ref e) => Some(e), + Self::Transactions(ref e) => Some(e), + Self::Removed(ref e) => Some(e), + Self::LastBlock(ref e) => Some(e), } } } @@ -153,20 +149,20 @@ pub enum TransactionItemError { impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TransactionItemError as E; match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::ReplacedByTxid(ref e) => + Self::ReplacedByTxid(ref e) => write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), - E::ReplacesTxid(ref e) => + Self::ReplacesTxid(ref e) => write_err!(f, "conversion of the `replaces_txid` field failed"; e), } } @@ -175,18 +171,17 @@ impl fmt::Display for TransactionItemError { #[cfg(feature = "std")] impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TransactionItemError as E; match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::ReplacedByTxid(ref e) => Some(e), - E::ReplacesTxid(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::ReplacedByTxid(ref e) => Some(e), + Self::ReplacesTxid(ref e) => Some(e), } } } @@ -208,12 +203,10 @@ pub enum SendAllError { impl fmt::Display for SendAllError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SendAllError as E; - match *self { - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), } } } @@ -221,12 +214,10 @@ impl fmt::Display for SendAllError { #[cfg(feature = "std")] impl std::error::Error for SendAllError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SendAllError as E; - match *self { - E::Txid(ref e) => Some(e), - E::Hex(ref e) => Some(e), - E::Psbt(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Psbt(ref e) => Some(e), } } } diff --git a/types/src/v25/blockchain/error.rs b/types/src/v25/blockchain/error.rs index b10043a3..84e1a115 100644 --- a/types/src/v25/blockchain/error.rs +++ b/types/src/v25/blockchain/error.rs @@ -18,11 +18,9 @@ pub enum ScanBlocksStartError { impl fmt::Display for ScanBlocksStartError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ScanBlocksStartError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::RelevantBlocks(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::RelevantBlocks(ref e) => write_err!(f, "conversion of the `relevant_blocks` field failed"; e), } } @@ -31,11 +29,9 @@ impl fmt::Display for ScanBlocksStartError { #[cfg(feature = "std")] impl std::error::Error for ScanBlocksStartError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ScanBlocksStartError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::RelevantBlocks(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::RelevantBlocks(ref e) => Some(e), } } } diff --git a/types/src/v25/generating/error.rs b/types/src/v25/generating/error.rs index 1d08e8a0..025a4fa3 100644 --- a/types/src/v25/generating/error.rs +++ b/types/src/v25/generating/error.rs @@ -18,11 +18,9 @@ pub enum GenerateBlockError { impl fmt::Display for GenerateBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GenerateBlockError::*; - match *self { - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), } } } @@ -30,11 +28,9 @@ impl fmt::Display for GenerateBlockError { #[cfg(feature = "std")] impl std::error::Error for GenerateBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GenerateBlockError::*; - match *self { - Hash(ref e) => Some(e), - Hex(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + Self::Hex(ref e) => Some(e), } } } diff --git a/types/src/v25/raw_transactions/error.rs b/types/src/v25/raw_transactions/error.rs index 3390c2a7..e5612080 100644 --- a/types/src/v25/raw_transactions/error.rs +++ b/types/src/v25/raw_transactions/error.rs @@ -17,10 +17,8 @@ pub enum TestMempoolAcceptError { impl fmt::Display for TestMempoolAcceptError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TestMempoolAcceptError as E; - match *self { - E::MempoolAcceptance(ref e) => + Self::MempoolAcceptance(ref e) => write_err!(f, "conversion of one of the mempool acceptance results failed"; e), } } @@ -29,10 +27,8 @@ impl fmt::Display for TestMempoolAcceptError { #[cfg(feature = "std")] impl std::error::Error for TestMempoolAcceptError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TestMempoolAcceptError as E; - match *self { - E::MempoolAcceptance(ref e) => Some(e), + Self::MempoolAcceptance(ref e) => Some(e), } } } @@ -58,14 +54,12 @@ pub enum MempoolAcceptanceError { impl fmt::Display for MempoolAcceptanceError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use MempoolAcceptanceError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "conversion of a numeric field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::Base(ref e) => write_err!(f, "conversion of the `base` fee field failed"; e), - E::Feerate(ref e) => + Self::Numeric(ref e) => write_err!(f, "conversion of a numeric field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::Base(ref e) => write_err!(f, "conversion of the `base` fee field failed"; e), + Self::Feerate(ref e) => write_err!(f, "conversion of the `effective-feerate` field failed"; e), } } @@ -74,14 +68,12 @@ impl fmt::Display for MempoolAcceptanceError { #[cfg(feature = "std")] impl std::error::Error for MempoolAcceptanceError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use MempoolAcceptanceError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::Base(ref e) => Some(e), - E::Feerate(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::Base(ref e) => Some(e), + Self::Feerate(ref e) => Some(e), } } } diff --git a/types/src/v26/blockchain/error.rs b/types/src/v26/blockchain/error.rs index ac572fc1..4a9307de 100644 --- a/types/src/v26/blockchain/error.rs +++ b/types/src/v26/blockchain/error.rs @@ -20,14 +20,12 @@ pub enum GetChainStatesError { impl fmt::Display for GetChainStatesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetChainStatesError::*; - match *self { - BestBlockHash(ref e) => + Self::BestBlockHash(ref e) => write_err!(f, "conversion of the `best_block_hash` field failed"; e), - SnapshotBlockHash(ref e) => + Self::SnapshotBlockHash(ref e) => write_err!(f, "conversion of the `snapshot_block_hash` field failed"; e), - Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -35,12 +33,10 @@ impl fmt::Display for GetChainStatesError { #[cfg(feature = "std")] impl std::error::Error for GetChainStatesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetChainStatesError::*; - match *self { - BestBlockHash(ref e) => Some(e), - SnapshotBlockHash(ref e) => Some(e), - Numeric(ref e) => Some(e), + Self::BestBlockHash(ref e) => Some(e), + Self::SnapshotBlockHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), } } } @@ -64,15 +60,13 @@ pub enum DumpTxOutSetError { impl fmt::Display for DumpTxOutSetError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DumpTxOutSetError::*; - match *self { - CoinsWritten(ref e) => + Self::CoinsWritten(ref e) => write_err!(f, "conversion of the `coins_written` field failed"; e), - BaseHash(ref e) => write_err!(f, "conversion of the `base_hash` field failed"; e), - TxOutSetHash(ref e) => + Self::BaseHash(ref e) => write_err!(f, "conversion of the `base_hash` field failed"; e), + Self::TxOutSetHash(ref e) => write_err!(f, "conversion of the `txoutset_hash` field failed"; e), - Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -80,13 +74,11 @@ impl fmt::Display for DumpTxOutSetError { #[cfg(feature = "std")] impl std::error::Error for DumpTxOutSetError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DumpTxOutSetError::*; - match *self { - CoinsWritten(ref e) => Some(e), - BaseHash(ref e) => Some(e), - TxOutSetHash(ref e) => Some(e), - Numeric(ref e) => Some(e), + Self::CoinsWritten(ref e) => Some(e), + Self::BaseHash(ref e) => Some(e), + Self::TxOutSetHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), } } } @@ -108,12 +100,12 @@ pub enum GetTxOutSetInfoError { impl fmt::Display for GetTxOutSetInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTxOutSetInfoError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - BestBlock(ref e) => write_err!(f, "conversion of the `beast_block` field failed"; e), - TotalAmount(ref e) => write_err!(f, "conversion of the `total_amount` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::BestBlock(ref e) => + write_err!(f, "conversion of the `beast_block` field failed"; e), + Self::TotalAmount(ref e) => + write_err!(f, "conversion of the `total_amount` field failed"; e), } } } @@ -121,12 +113,10 @@ impl fmt::Display for GetTxOutSetInfoError { #[cfg(feature = "std")] impl std::error::Error for GetTxOutSetInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTxOutSetInfoError::*; - match *self { - Numeric(ref e) => Some(e), - BestBlock(ref e) => Some(e), - TotalAmount(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::BestBlock(ref e) => Some(e), + Self::TotalAmount(ref e) => Some(e), } } } @@ -148,12 +138,11 @@ pub enum LoadTxOutSetError { impl fmt::Display for LoadTxOutSetError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use LoadTxOutSetError::*; - match *self { - CoinsLoaded(ref e) => write_err!(f, "conversion of the `coins_loaded` field failed"; e), - TipHash(ref e) => write_err!(f, "conversion of the `tip_hash` field failed"; e), - Numeric(ref e) => write_err!(f, "numeric"; e), + Self::CoinsLoaded(ref e) => + write_err!(f, "conversion of the `coins_loaded` field failed"; e), + Self::TipHash(ref e) => write_err!(f, "conversion of the `tip_hash` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -161,12 +150,10 @@ impl fmt::Display for LoadTxOutSetError { #[cfg(feature = "std")] impl std::error::Error for LoadTxOutSetError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use LoadTxOutSetError::*; - match *self { - CoinsLoaded(ref e) => Some(e), - TipHash(ref e) => Some(e), - Numeric(ref e) => Some(e), + Self::CoinsLoaded(ref e) => Some(e), + Self::TipHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), } } } diff --git a/types/src/v26/raw_transactions/error.rs b/types/src/v26/raw_transactions/error.rs index 775e949d..c090bd48 100644 --- a/types/src/v26/raw_transactions/error.rs +++ b/types/src/v26/raw_transactions/error.rs @@ -21,11 +21,9 @@ pub enum DescriptorProcessPsbtError { impl fmt::Display for DescriptorProcessPsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use DescriptorProcessPsbtError as E; - match *self { - E::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), - E::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Psbt(ref e) => write_err!(f, "conversion of the `psbt` field failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), } } } @@ -33,11 +31,9 @@ impl fmt::Display for DescriptorProcessPsbtError { #[cfg(feature = "std")] impl std::error::Error for DescriptorProcessPsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use DescriptorProcessPsbtError as E; - match *self { - E::Psbt(ref e) => Some(e), - E::Hex(ref e) => Some(e), + Self::Psbt(ref e) => Some(e), + Self::Hex(ref e) => Some(e), } } } @@ -55,14 +51,12 @@ pub enum SubmitPackageError { impl fmt::Display for SubmitPackageError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SubmitPackageError as E; - match *self { - E::TxResultKey(ref e) => + Self::TxResultKey(ref e) => write_err!(f, "conversion of key from `tx_results` map failed"; e), - E::TxResultValue(ref e) => + Self::TxResultValue(ref e) => write_err!(f, "conversion of value from `tx_results` map failed"; e), - E::ReplaceTransactions(ref e) => + Self::ReplaceTransactions(ref e) => write_err!(f, "conversion of a list item from `replaced_transactions` field failed"; e), } } @@ -71,12 +65,10 @@ impl fmt::Display for SubmitPackageError { #[cfg(feature = "std")] impl std::error::Error for SubmitPackageError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SubmitPackageError as E; - match *self { - E::TxResultKey(ref e) => Some(e), - E::TxResultValue(ref e) => Some(e), - E::ReplaceTransactions(ref e) => Some(e), + Self::TxResultKey(ref e) => Some(e), + Self::TxResultValue(ref e) => Some(e), + Self::ReplaceTransactions(ref e) => Some(e), } } } @@ -96,14 +88,12 @@ pub enum SubmitPackageTxResultError { impl fmt::Display for SubmitPackageTxResultError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SubmitPackageTxResultError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::OtherWtxid(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::OtherWtxid(ref e) => write_err!(f, "conversion of the `other_wtxid` field failed"; e), - E::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), + Self::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), } } } @@ -111,13 +101,11 @@ impl fmt::Display for SubmitPackageTxResultError { #[cfg(feature = "std")] impl std::error::Error for SubmitPackageTxResultError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SubmitPackageTxResultError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::OtherWtxid(ref e) => Some(e), - E::Fees(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::OtherWtxid(ref e) => Some(e), + Self::Fees(ref e) => Some(e), } } } @@ -139,13 +127,11 @@ pub enum SubmitPackageTxResultFeesError { impl fmt::Display for SubmitPackageTxResultFeesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SubmitPackageTxResultFeesError as E; - match *self { - E::BaseFee(ref e) => write_err!(f, "conversion of the `base_fee` field failed"; e), - E::EffectiveFeeRate(ref e) => + Self::BaseFee(ref e) => write_err!(f, "conversion of the `base_fee` field failed"; e), + Self::EffectiveFeeRate(ref e) => write_err!(f, "conversion of the `effective_fee_rate` field failed"; e), - E::EffectiveIncludes(ref e) => write_err!(f, "effective_includes"; e), + Self::EffectiveIncludes(ref e) => write_err!(f, "effective_includes"; e), } } } @@ -153,12 +139,10 @@ impl fmt::Display for SubmitPackageTxResultFeesError { #[cfg(feature = "std")] impl std::error::Error for SubmitPackageTxResultFeesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SubmitPackageTxResultFeesError as E; - match *self { - E::BaseFee(ref e) => Some(e), - E::EffectiveFeeRate(ref e) => Some(e), - E::EffectiveIncludes(ref e) => Some(e), + Self::BaseFee(ref e) => Some(e), + Self::EffectiveFeeRate(ref e) => Some(e), + Self::EffectiveIncludes(ref e) => Some(e), } } } diff --git a/types/src/v26/wallet/error.rs b/types/src/v26/wallet/error.rs index ef22b2a7..475c1ae8 100644 --- a/types/src/v26/wallet/error.rs +++ b/types/src/v26/wallet/error.rs @@ -23,12 +23,11 @@ pub enum GetBalancesError { impl fmt::Display for GetBalancesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBalancesError as E; - match *self { - E::Mine(ref e) => write_err!(f, "conversion of the `mine` field failed"; e), - E::WatchOnly(ref e) => write_err!(f, "conversion of the `watchonly` field failed"; e), - E::LastProcessedBlock(ref e) => + Self::Mine(ref e) => write_err!(f, "conversion of the `mine` field failed"; e), + Self::WatchOnly(ref e) => + write_err!(f, "conversion of the `watchonly` field failed"; e), + Self::LastProcessedBlock(ref e) => write_err!(f, "conversion of the `last_processed_block` field failed"; e), } } @@ -37,12 +36,10 @@ impl fmt::Display for GetBalancesError { #[cfg(feature = "std")] impl std::error::Error for GetBalancesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBalancesError as E; - match *self { - E::Mine(ref e) => Some(e), - E::WatchOnly(ref e) => Some(e), - E::LastProcessedBlock(ref e) => Some(e), + Self::Mine(ref e) => Some(e), + Self::WatchOnly(ref e) => Some(e), + Self::LastProcessedBlock(ref e) => Some(e), } } } @@ -80,26 +77,25 @@ pub enum GetTransactionError { impl fmt::Display for GetTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::ReplacedByTxid(ref e) => + Self::ReplacedByTxid(ref e) => write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), - E::ReplacesTxid(ref e) => + Self::ReplacesTxid(ref e) => write_err!(f, "conversion of the `replaces_txid` field failed"; e), - E::MempoolConflicts(ref e) => + Self::MempoolConflicts(ref e) => write_err!(f, "conversion of the `mempool_conflicts` field failed"; e), - E::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), - E::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), - E::LastProcessedBlock(ref e) => + Self::Tx(ref e) => write_err!(f, "conversion of the `hex` field failed"; e), + Self::Details(ref e) => write_err!(f, "conversion of the `details` field failed"; e), + Self::LastProcessedBlock(ref e) => write_err!(f, "conversion of the `last_processed_block` field failed"; e), } } @@ -108,22 +104,20 @@ impl fmt::Display for GetTransactionError { #[cfg(feature = "std")] impl std::error::Error for GetTransactionError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetTransactionError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::ReplacedByTxid(ref e) => Some(e), - E::ReplacesTxid(ref e) => Some(e), - E::MempoolConflicts(ref e) => Some(e), - E::Tx(ref e) => Some(e), - E::Details(ref e) => Some(e), - E::LastProcessedBlock(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::ReplacedByTxid(ref e) => Some(e), + Self::ReplacesTxid(ref e) => Some(e), + Self::MempoolConflicts(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Details(ref e) => Some(e), + Self::LastProcessedBlock(ref e) => Some(e), } } } @@ -153,17 +147,18 @@ pub enum GetWalletInfoError { impl fmt::Display for GetWalletInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetWalletInfoError::*; match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Balance(ref e) => write_err!(f, "conversion of the `balance` field failed"; e), - UnconfirmedBalance(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Balance(ref e) => write_err!(f, "conversion of the `balance` field failed"; e), + Self::UnconfirmedBalance(ref e) => write_err!(f, "conversion of the `unconfirmed_balance` field failed"; e), - ImmatureBalance(ref e) => + Self::ImmatureBalance(ref e) => write_err!(f, "conversion of the `immature_balance` field failed"; e), - PayTxFee(ref e) => write_err!(f, "conversion of the `pay_tx_fee` field failed"; e), - HdSeedId(ref e) => write_err!(f, "conversion of the `hd_seed_id` field failed"; e), - LastProcessedBlock(ref e) => + Self::PayTxFee(ref e) => + write_err!(f, "conversion of the `pay_tx_fee` field failed"; e), + Self::HdSeedId(ref e) => + write_err!(f, "conversion of the `hd_seed_id` field failed"; e), + Self::LastProcessedBlock(ref e) => write_err!(f, "conversion of the `last_processed_block` field failed"; e), } } @@ -172,15 +167,14 @@ impl fmt::Display for GetWalletInfoError { #[cfg(feature = "std")] impl std::error::Error for GetWalletInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetWalletInfoError::*; match *self { - Numeric(ref e) => Some(e), - Balance(ref e) => Some(e), - UnconfirmedBalance(ref e) => Some(e), - ImmatureBalance(ref e) => Some(e), - PayTxFee(ref e) => Some(e), - HdSeedId(ref e) => Some(e), - LastProcessedBlock(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Balance(ref e) => Some(e), + Self::UnconfirmedBalance(ref e) => Some(e), + Self::ImmatureBalance(ref e) => Some(e), + Self::PayTxFee(ref e) => Some(e), + Self::HdSeedId(ref e) => Some(e), + Self::LastProcessedBlock(ref e) => Some(e), } } } @@ -200,11 +194,9 @@ pub enum LastProcessedBlockError { impl fmt::Display for LastProcessedBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use LastProcessedBlockError::*; - match *self { - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - Height(ref e) => write_err!(f, "conversion of the `height` field failed"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Height(ref e) => write_err!(f, "conversion of the `height` field failed"; e), } } } @@ -212,11 +204,9 @@ impl fmt::Display for LastProcessedBlockError { #[cfg(feature = "std")] impl std::error::Error for LastProcessedBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use LastProcessedBlockError::*; - match *self { - Hash(ref e) => Some(e), - Height(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + Self::Height(ref e) => Some(e), } } } @@ -236,9 +226,9 @@ pub enum WalletProcessPsbtError { impl fmt::Display for WalletProcessPsbtError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - WalletProcessPsbtError::Psbt(e) => write!(f, "psbt parse error: {}", e), - WalletProcessPsbtError::Hex(e) => write!(f, "hex decode error: {}", e), + match *self { + Self::Psbt(ref e) => write!(f, "psbt parse error: {}", e), + Self::Hex(ref e) => write!(f, "hex decode error: {}", e), } } } @@ -246,9 +236,9 @@ impl fmt::Display for WalletProcessPsbtError { #[cfg(feature = "std")] impl std::error::Error for WalletProcessPsbtError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - WalletProcessPsbtError::Psbt(e) => Some(e), - WalletProcessPsbtError::Hex(e) => Some(e), + match *self { + Self::Psbt(ref e) => Some(e), + Self::Hex(ref e) => Some(e), } } } diff --git a/types/src/v28/raw_transactions/error.rs b/types/src/v28/raw_transactions/error.rs index 007b6d12..2bb683af 100644 --- a/types/src/v28/raw_transactions/error.rs +++ b/types/src/v28/raw_transactions/error.rs @@ -21,14 +21,12 @@ pub enum SubmitPackageError { impl fmt::Display for SubmitPackageError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SubmitPackageError as E; - match *self { - E::TxResultKey(ref e) => + Self::TxResultKey(ref e) => write_err!(f, "conversion of key from `tx_results` map failed"; e), - E::TxResultValue(ref e) => + Self::TxResultValue(ref e) => write_err!(f, "conversion of value from `tx_results` map failed"; e), - E::ReplaceTransactions(ref e) => + Self::ReplaceTransactions(ref e) => write_err!(f, "conversion of a list item from `replaced_transactions` field failed"; e), } } @@ -37,12 +35,10 @@ impl fmt::Display for SubmitPackageError { #[cfg(feature = "std")] impl std::error::Error for SubmitPackageError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SubmitPackageError as E; - match *self { - E::TxResultKey(ref e) => Some(e), - E::TxResultValue(ref e) => Some(e), - E::ReplaceTransactions(ref e) => Some(e), + Self::TxResultKey(ref e) => Some(e), + Self::TxResultValue(ref e) => Some(e), + Self::ReplaceTransactions(ref e) => Some(e), } } } @@ -62,14 +58,12 @@ pub enum SubmitPackageTxResultError { impl fmt::Display for SubmitPackageTxResultError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SubmitPackageTxResultError as E; - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::OtherWtxid(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::OtherWtxid(ref e) => write_err!(f, "conversion of the `other_wtxid` field failed"; e), - E::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), + Self::Fees(ref e) => write_err!(f, "conversion of the `fees` field failed"; e), } } } @@ -77,13 +71,11 @@ impl fmt::Display for SubmitPackageTxResultError { #[cfg(feature = "std")] impl std::error::Error for SubmitPackageTxResultError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SubmitPackageTxResultError as E; - match *self { - E::Numeric(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::OtherWtxid(ref e) => Some(e), - E::Fees(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::OtherWtxid(ref e) => Some(e), + Self::Fees(ref e) => Some(e), } } } @@ -105,13 +97,11 @@ pub enum SubmitPackageTxResultFeesError { impl fmt::Display for SubmitPackageTxResultFeesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SubmitPackageTxResultFeesError as E; - match *self { - E::BaseFee(ref e) => write_err!(f, "conversion of the `base_fee` field failed"; e), - E::EffectiveFeeRate(ref e) => + Self::BaseFee(ref e) => write_err!(f, "conversion of the `base_fee` field failed"; e), + Self::EffectiveFeeRate(ref e) => write_err!(f, "conversion of the `effective_fee_rate` field failed"; e), - E::EffectiveIncludes(ref e) => write_err!(f, "effective_includes"; e), + Self::EffectiveIncludes(ref e) => write_err!(f, "effective_includes"; e), } } } @@ -119,12 +109,10 @@ impl fmt::Display for SubmitPackageTxResultFeesError { #[cfg(feature = "std")] impl std::error::Error for SubmitPackageTxResultFeesError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use SubmitPackageTxResultFeesError as E; - match *self { - E::BaseFee(ref e) => Some(e), - E::EffectiveFeeRate(ref e) => Some(e), - E::EffectiveIncludes(ref e) => Some(e), + Self::BaseFee(ref e) => Some(e), + Self::EffectiveFeeRate(ref e) => Some(e), + Self::EffectiveIncludes(ref e) => Some(e), } } } diff --git a/types/src/v28/wallet/error.rs b/types/src/v28/wallet/error.rs index 27ff4154..2d0434b4 100644 --- a/types/src/v28/wallet/error.rs +++ b/types/src/v28/wallet/error.rs @@ -21,11 +21,10 @@ pub enum GetHdKeysError { impl fmt::Display for GetHdKeysError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetHdKeysError::*; match *self { - Xpub(ref e) => write_err!(f, "conversion of the `xpub` field failed"; e), - Xpriv(ref e) => write_err!(f, "conversion of the `xpriv` field failed"; e), - Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Xpub(ref e) => write_err!(f, "conversion of the `xpub` field failed"; e), + Self::Xpriv(ref e) => write_err!(f, "conversion of the `xpriv` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -33,11 +32,10 @@ impl fmt::Display for GetHdKeysError { #[cfg(feature = "std")] impl std::error::Error for GetHdKeysError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetHdKeysError::*; match *self { - Xpub(ref e) => Some(e), - Xpriv(ref e) => Some(e), - Numeric(ref e) => Some(e), + Self::Xpub(ref e) => Some(e), + Self::Xpriv(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), } } } @@ -59,12 +57,12 @@ pub enum ListSinceBlockError { impl fmt::Display for ListSinceBlockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockError::*; match *self { - Transactions(ref e) => + Self::Transactions(ref e) => write_err!(f, "conversion of the `transactions` field failed"; e), - Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), - LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + Self::Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + Self::LastBlock(ref e) => + write_err!(f, "conversion of the `last_block` field failed"; e), } } } @@ -72,11 +70,10 @@ impl fmt::Display for ListSinceBlockError { #[cfg(feature = "std")] impl std::error::Error for ListSinceBlockError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockError::*; match *self { - Transactions(ref e) => Some(e), - Removed(ref e) => Some(e), - LastBlock(ref e) => Some(e), + Self::Transactions(ref e) => Some(e), + Self::Removed(ref e) => Some(e), + Self::LastBlock(ref e) => Some(e), } } } @@ -108,20 +105,20 @@ pub enum TransactionItemError { impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use TransactionItemError as E; match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), - E::WalletConflicts(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + Self::BlockHash(ref e) => + write_err!(f, "conversion of the `block_hash` field failed"; e), + Self::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + Self::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + Self::WalletConflicts(ref e) => write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), - E::ReplacedByTxid(ref e) => + Self::ReplacedByTxid(ref e) => write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), - E::ReplacesTxid(ref e) => + Self::ReplacesTxid(ref e) => write_err!(f, "conversion of the `replaces_txid` field failed"; e), } } @@ -130,18 +127,17 @@ impl fmt::Display for TransactionItemError { #[cfg(feature = "std")] impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use TransactionItemError as E; match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - E::Wtxid(ref e) => Some(e), - E::WalletConflicts(ref e) => Some(e), - E::ReplacedByTxid(ref e) => Some(e), - E::ReplacesTxid(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Address(ref e) => Some(e), + Self::Amount(ref e) => Some(e), + Self::Fee(ref e) => Some(e), + Self::BlockHash(ref e) => Some(e), + Self::Txid(ref e) => Some(e), + Self::Wtxid(ref e) => Some(e), + Self::WalletConflicts(ref e) => Some(e), + Self::ReplacedByTxid(ref e) => Some(e), + Self::ReplacesTxid(ref e) => Some(e), } } } diff --git a/types/src/v29/blockchain/error.rs b/types/src/v29/blockchain/error.rs index a237a3e7..92be2df6 100644 --- a/types/src/v29/blockchain/error.rs +++ b/types/src/v29/blockchain/error.rs @@ -33,18 +33,17 @@ pub enum GetBlockVerboseOneError { impl fmt::Display for GetBlockVerboseOneError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockVerboseOneError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e), - Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), - PreviousBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e), + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::PreviousBlockHash(ref e) => write_err!(f, "conversion of the `previous_block_hash` field failed"; e), - NextBlockHash(ref e) => + Self::NextBlockHash(ref e) => write_err!(f, "conversion of the `next_block_hash` field failed"; e), } } @@ -53,17 +52,15 @@ impl fmt::Display for GetBlockVerboseOneError { #[cfg(feature = "std")] impl std::error::Error for GetBlockVerboseOneError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockVerboseOneError::*; - match *self { - Numeric(ref e) => Some(e), - Hash(ref e) => Some(e), - Tx(ref e) => Some(e), - Bits(ref e) => Some(e), - Target(ref e) => Some(e), - ChainWork(ref e) => Some(e), - PreviousBlockHash(ref e) => Some(e), - NextBlockHash(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + Self::Tx(ref e) => Some(e), + Self::Bits(ref e) => Some(e), + Self::Target(ref e) => Some(e), + Self::ChainWork(ref e) => Some(e), + Self::PreviousBlockHash(ref e) => Some(e), + Self::NextBlockHash(ref e) => Some(e), } } } @@ -93,17 +90,16 @@ pub enum GetBlockchainInfoError { impl fmt::Display for GetBlockchainInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockchainInfoError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e), - BestBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Chain(ref e) => write_err!(f, "conversion of the `chain` field failed"; e), + Self::BestBlockHash(ref e) => write_err!(f, "conversion of the `best_block_hash` field failed"; e), - Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), - SignetChallenge(ref e) => + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::SignetChallenge(ref e) => write_err!(f, "conversion of the `signet_challenge` field failed"; e), } } @@ -112,16 +108,14 @@ impl fmt::Display for GetBlockchainInfoError { #[cfg(feature = "std")] impl std::error::Error for GetBlockchainInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockchainInfoError::*; - match *self { - Numeric(ref e) => Some(e), - Chain(ref e) => Some(e), - Bits(ref e) => Some(e), - Target(ref e) => Some(e), - BestBlockHash(ref e) => Some(e), - ChainWork(ref e) => Some(e), - SignetChallenge(ref e) => Some(e), + Self::Numeric(ref e) => Some(e), + Self::Chain(ref e) => Some(e), + Self::Bits(ref e) => Some(e), + Self::Target(ref e) => Some(e), + Self::BestBlockHash(ref e) => Some(e), + Self::ChainWork(ref e) => Some(e), + Self::SignetChallenge(ref e) => Some(e), } } } @@ -145,11 +139,10 @@ pub enum GetBlockHeaderError { impl fmt::Display for GetBlockHeaderError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockHeaderError::*; - match *self { - Hex(ref e) => write_err!(f, "conversion of hex data to bytes failed"; e), - Consensus(ref e) => write_err!(f, "consensus decoding of bytes to header failed"; e), + Self::Hex(ref e) => write_err!(f, "conversion of hex data to bytes failed"; e), + Self::Consensus(ref e) => + write_err!(f, "consensus decoding of bytes to header failed"; e), } } } @@ -157,11 +150,9 @@ impl fmt::Display for GetBlockHeaderError { #[cfg(feature = "std")] impl std::error::Error for GetBlockHeaderError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetBlockHeaderError::*; - match *self { - Hex(ref e) => Some(e), - Consensus(ref e) => Some(e), + Self::Hex(ref e) => Some(e), + Self::Consensus(ref e) => Some(e), } } } @@ -189,18 +180,18 @@ pub enum GetBlockHeaderVerboseError { impl fmt::Display for GetBlockHeaderVerboseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetBlockHeaderVerboseError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric"; e), - Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), - MerkleRoot(ref e) => write_err!(f, "conversion of the `merkle_root` field failed"; e), - Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), - ChainWork(ref e) => write_err!(f, "conversion of the `chain_work` field failed"; e), - PreviousBlockHash(ref e) => + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + Self::MerkleRoot(ref e) => + write_err!(f, "conversion of the `merkle_root` field failed"; e), + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::ChainWork(ref e) => + write_err!(f, "conversion of the `chain_work` field failed"; e), + Self::PreviousBlockHash(ref e) => write_err!(f, "conversion of the `previous_block_hash` field failed"; e), - NextBlockHash(ref e) => + Self::NextBlockHash(ref e) => write_err!(f, "conversion of the `next_block_hash` field failed"; e), } } @@ -245,16 +236,14 @@ pub enum GetChainStatesError { impl fmt::Display for GetChainStatesError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetChainStatesError::*; - match *self { - BestBlockHash(ref e) => + Self::BestBlockHash(ref e) => write_err!(f, "conversion of the `best_block_hash` field failed"; e), - Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), - SnapshotBlockHash(ref e) => + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::SnapshotBlockHash(ref e) => write_err!(f, "conversion of the `snapshot_block_hash` field failed"; e), - Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Numeric(ref e) => write_err!(f, "numeric"; e), } } } @@ -303,17 +292,18 @@ pub enum GetDescriptorActivityError { impl fmt::Display for GetDescriptorActivityError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetDescriptorActivityError::*; - match *self { - Numeric(ref e) => write_err!(f, "numeric conversion failed"; e), - Hash(ref e) => write_err!(f, "conversion of a hash string failed"; e), - Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - Script(ref e) => write_err!(f, "conversion of the script `hex` field failed"; e), - Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - ActivityEntry(ref e) => write_err!(f, "conversion of an activity entry failed"; e), - PrevoutSpk(ref e) => write_err!(f, "conversion of the `prevout_spk` field failed"; e), - OutputSpk(ref e) => write_err!(f, "conversion of the `output_spk` field failed"; e), + Self::Numeric(ref e) => write_err!(f, "numeric conversion failed"; e), + Self::Hash(ref e) => write_err!(f, "conversion of a hash string failed"; e), + Self::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + Self::Script(ref e) => write_err!(f, "conversion of the script `hex` field failed"; e), + Self::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + Self::ActivityEntry(ref e) => + write_err!(f, "conversion of an activity entry failed"; e), + Self::PrevoutSpk(ref e) => + write_err!(f, "conversion of the `prevout_spk` field failed"; e), + Self::OutputSpk(ref e) => + write_err!(f, "conversion of the `output_spk` field failed"; e), } } } diff --git a/types/src/v29/mining/error.rs b/types/src/v29/mining/error.rs index efb406de..d13b691b 100644 --- a/types/src/v29/mining/error.rs +++ b/types/src/v29/mining/error.rs @@ -19,12 +19,10 @@ pub enum GetMiningInfoError { impl fmt::Display for GetMiningInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use GetMiningInfoError as E; - match *self { - E::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - E::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), - E::Next(ref e) => + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::Next(ref e) => write_err!(f, "conversion of one of the items in field `next` failed"; e), } } @@ -33,12 +31,10 @@ impl fmt::Display for GetMiningInfoError { #[cfg(feature = "std")] impl std::error::Error for GetMiningInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use GetMiningInfoError as E; - match *self { - E::Bits(ref e) => Some(e), - E::Target(ref e) => Some(e), - E::Next(ref e) => Some(e), + Self::Bits(ref e) => Some(e), + Self::Target(ref e) => Some(e), + Self::Next(ref e) => Some(e), } } } @@ -54,11 +50,9 @@ pub enum NextBlockInfoError { impl fmt::Display for NextBlockInfoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use NextBlockInfoError as E; - match *self { - E::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), - E::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), + Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e), + Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e), } } } @@ -66,11 +60,9 @@ impl fmt::Display for NextBlockInfoError { #[cfg(feature = "std")] impl std::error::Error for NextBlockInfoError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use NextBlockInfoError as E; - match *self { - E::Bits(ref e) => Some(e), - E::Target(ref e) => Some(e), + Self::Bits(ref e) => Some(e), + Self::Target(ref e) => Some(e), } } }