From: Luis Schwab Date: Fri, 6 Mar 2026 01:02:06 +0000 (-0300) Subject: chore: use `core::error::Error` X-Git-Url: http://internal-gitweb-vhost/parse/src/example_cli/%22https:/enum.InsertCheckpointError.html?a=commitdiff_plain;h=2a92fd365ea7f45e56b3027989b5cdf79ef4773a;p=bdk chore: use `core::error::Error` The `Error` trait is stable as of 1.81.0, so import it from `core` instead. --- diff --git a/crates/bitcoind_rpc/src/bip158.rs b/crates/bitcoind_rpc/src/bip158.rs index 81963def..4caf59fc 100644 --- a/crates/bitcoind_rpc/src/bip158.rs +++ b/crates/bitcoind_rpc/src/bip158.rs @@ -173,8 +173,7 @@ impl core::fmt::Display for Error { } } -#[cfg(feature = "std")] -impl std::error::Error for Error {} +impl core::error::Error for Error {} impl From for Error { fn from(e: bitcoincore_rpc::Error) -> Self { diff --git a/crates/chain/src/indexer/keychain_txout.rs b/crates/chain/src/indexer/keychain_txout.rs index 6f977b8e..cbad6669 100644 --- a/crates/chain/src/indexer/keychain_txout.rs +++ b/crates/chain/src/indexer/keychain_txout.rs @@ -1022,8 +1022,7 @@ impl core::fmt::Display for InsertDescriptorError { } } -#[cfg(feature = "std")] -impl std::error::Error for InsertDescriptorError {} +impl core::error::Error for InsertDescriptorError {} /// `ChangeSet` represents persistent updates to a [`KeychainTxOutIndex`]. /// diff --git a/crates/chain/src/indexer/spk_txout.rs b/crates/chain/src/indexer/spk_txout.rs index 2bf78ec2..e63eb120 100644 --- a/crates/chain/src/indexer/spk_txout.rs +++ b/crates/chain/src/indexer/spk_txout.rs @@ -332,7 +332,7 @@ impl SpkTxOutIndex { /// # use bitcoin::{Address, Network, Transaction}; /// # use std::str::FromStr; /// # - /// # fn example() -> Result<(), Box> { + /// # fn example() -> Result<(), Box> { /// let mut index = SpkTxOutIndex::::default(); /// /// // ... scan transactions to populate the index ... @@ -382,7 +382,7 @@ impl SpkTxOutIndex { /// # use bitcoin::{Address, Network, Transaction}; /// # use std::str::FromStr; /// # - /// # fn example() -> Result<(), Box> { + /// # fn example() -> Result<(), Box> { /// let mut index = SpkTxOutIndex::::default(); /// /// // ... scan transactions to populate the index ... diff --git a/crates/chain/src/local_chain.rs b/crates/chain/src/local_chain.rs index 81f4a179..5bfff3aa 100644 --- a/crates/chain/src/local_chain.rs +++ b/crates/chain/src/local_chain.rs @@ -498,8 +498,7 @@ impl core::fmt::Display for MissingGenesisError { } } -#[cfg(feature = "std")] -impl std::error::Error for MissingGenesisError {} +impl core::error::Error for MissingGenesisError {} /// Represents a failure when trying to insert/remove a checkpoint to/from [`LocalChain`]. #[derive(Clone, Debug, PartialEq)] @@ -529,8 +528,7 @@ impl core::fmt::Display for AlterCheckPointError { } } -#[cfg(feature = "std")] -impl std::error::Error for AlterCheckPointError {} +impl core::error::Error for AlterCheckPointError {} /// Occurs when an update does not have a common checkpoint with the original chain. #[derive(Clone, Debug, PartialEq)] @@ -549,8 +547,7 @@ impl core::fmt::Display for CannotConnectError { } } -#[cfg(feature = "std")] -impl std::error::Error for CannotConnectError {} +impl core::error::Error for CannotConnectError {} /// The error type for [`LocalChain::apply_header_connected_to`]. #[derive(Debug, Clone, PartialEq)] @@ -573,8 +570,7 @@ impl core::fmt::Display for ApplyHeaderError { } } -#[cfg(feature = "std")] -impl std::error::Error for ApplyHeaderError {} +impl core::error::Error for ApplyHeaderError {} /// Applies `update_tip` onto `original_tip`. /// diff --git a/crates/chain/src/rusqlite_impl.rs b/crates/chain/src/rusqlite_impl.rs index 7e9e2f6f..ad89f429 100644 --- a/crates/chain/src/rusqlite_impl.rs +++ b/crates/chain/src/rusqlite_impl.rs @@ -185,11 +185,11 @@ impl ToSql for Impl { } } -fn from_sql_error(err: E) -> FromSqlError { +fn from_sql_error(err: E) -> FromSqlError { FromSqlError::Other(Box::new(err)) } -fn to_sql_error(err: E) -> rusqlite::Error { +fn to_sql_error(err: E) -> rusqlite::Error { rusqlite::Error::ToSqlConversionFailure(Box::new(err)) } diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 701de335..44c34c2d 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -287,8 +287,7 @@ impl fmt::Display for CalculateFeeError { } } -#[cfg(feature = "std")] -impl std::error::Error for CalculateFeeError {} +impl core::error::Error for CalculateFeeError {} impl TxGraph { /// Iterate over all tx outputs known by [`TxGraph`]. diff --git a/crates/file_store/src/lib.rs b/crates/file_store/src/lib.rs index 5a7d5030..3731d503 100644 --- a/crates/file_store/src/lib.rs +++ b/crates/file_store/src/lib.rs @@ -53,4 +53,4 @@ impl From for StoreError { } } -impl std::error::Error for StoreError {} +impl core::error::Error for StoreError {} diff --git a/crates/file_store/src/store.rs b/crates/file_store/src/store.rs index 7e186792..858b9d2c 100644 --- a/crates/file_store/src/store.rs +++ b/crates/file_store/src/store.rs @@ -278,7 +278,7 @@ impl std::fmt::Display for StoreErrorWithDump { } } -impl std::error::Error for StoreErrorWithDump {} +impl core::error::Error for StoreErrorWithDump {} #[cfg(test)] #[cfg_attr(coverage_nightly, coverage(off))] diff --git a/examples/example_cli/src/lib.rs b/examples/example_cli/src/lib.rs index 2b910a1a..6745ae6c 100644 --- a/examples/example_cli/src/lib.rs +++ b/examples/example_cli/src/lib.rs @@ -268,7 +268,7 @@ pub fn create_tx( feerate: f32, ) -> anyhow::Result<(Psbt, Option)> where - O::Error: std::error::Error + Send + Sync + 'static, + O::Error: core::error::Error + Send + Sync + 'static, { let mut changeset = keychain_txout::ChangeSet::default();