From 7319f510016014a2ce4f9ab6e194e36345829357 Mon Sep 17 00:00:00 2001 From: nymius <155548262+nymius@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:58:36 -0300 Subject: [PATCH] refactor(chain)!: remove AnchorImpl wrapper for Anchor implementors AnchorImpl was a wrapper created to allow the implementation of foreign traits, like From/ToJson from serde_json for external unknown structs implementing the Anchor trait. As the Anchor generic in the rusqlite implementation for anchored ChangeSets was the only place where this AnchorImpl was used and it has been fixed to the anchor ConfirmationBlockTime, there is no more reason to keep this wrapper around. --- crates/chain/src/lib.rs | 24 ------------------------ crates/chain/src/rusqlite_impl.rs | 16 ---------------- 2 files changed, 40 deletions(-) diff --git a/crates/chain/src/lib.rs b/crates/chain/src/lib.rs index 8d87da58..557d5349 100644 --- a/crates/chain/src/lib.rs +++ b/crates/chain/src/lib.rs @@ -100,27 +100,3 @@ impl core::ops::Deref for Impl { &self.0 } } - -/// A wrapper that we use to impl remote traits for types in our crate or dependency crates that impl [`Anchor`]. -pub struct AnchorImpl(pub T); - -impl AnchorImpl { - /// Returns the inner `T`. - pub fn into_inner(self) -> T { - self.0 - } -} - -impl From for AnchorImpl { - fn from(value: T) -> Self { - Self(value) - } -} - -impl core::ops::Deref for AnchorImpl { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} diff --git a/crates/chain/src/rusqlite_impl.rs b/crates/chain/src/rusqlite_impl.rs index 6b722827..f3abca0f 100644 --- a/crates/chain/src/rusqlite_impl.rs +++ b/crates/chain/src/rusqlite_impl.rs @@ -157,22 +157,6 @@ impl ToSql for Impl { } } -impl FromSql for AnchorImpl { - fn column_result(value: ValueRef<'_>) -> FromSqlResult { - serde_json::from_str(value.as_str()?) - .map(AnchorImpl) - .map_err(from_sql_error) - } -} - -impl ToSql for AnchorImpl { - fn to_sql(&self) -> rusqlite::Result> { - serde_json::to_string(&self.0) - .map(Into::into) - .map_err(to_sql_error) - } -} - #[cfg(feature = "miniscript")] impl FromSql for Impl> { fn column_result(value: ValueRef<'_>) -> FromSqlResult { -- 2.49.0