diff --git a/CHANGELOG.md b/CHANGELOG.md index 26dba8f..5867aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Support for sqlx @ 0.8 ([#400]) + +### Removed + +- Support for sqlx @ 0.7. This is a breaking change, outside of + regular semver policy, as 0.7 contains a security vulnerability ([#400]) + +[#400]: https://github.com/recmo/uint/pull/400 + ## [1.12.3] - 2024-06-03 ### Changed diff --git a/Cargo.toml b/Cargo.toml index 75e0b8c..961b1d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,7 @@ bytes = { version = "1.4", optional = true } postgres-types = { version = "0.2", optional = true } # sqlx -sqlx-core = { version = "0.7", optional = true } +sqlx-core = { version = "0.8.2", optional = true } [dev-dependencies] ruint = { path = ".", features = ["arbitrary", "proptest"] } diff --git a/src/support/scale.rs b/src/support/scale.rs index 765c437..243dddb 100644 --- a/src/support/scale.rs +++ b/src/support/scale.rs @@ -97,7 +97,7 @@ impl<'a, const BITS: usize, const LIMBS: usize> EncodeAsRef<'a, Uint; } -impl<'a, const BITS: usize, const LIMBS: usize> EncodeLike for CompactRefUint<'a, BITS, LIMBS> {} +impl EncodeLike for CompactRefUint<'_, BITS, LIMBS> {} /// Compact/general integers are encoded with the two least significant bits /// denoting the mode: @@ -112,7 +112,7 @@ impl<'a, const BITS: usize, const LIMBS: usize> EncodeLike for CompactRefUint<'a /// following, plus four. The value is contained, LE encoded, in the bytes /// following. The final (most significant) byte must be non-zero. Valid only /// for values of `(2\*\*30)-(2\*\*536-1)`. -impl<'a, const BITS: usize, const LIMBS: usize> Encode for CompactRefUint<'a, BITS, LIMBS> { +impl Encode for CompactRefUint<'_, BITS, LIMBS> { fn size_hint(&self) -> usize { match self.0.bit_len() { 0..=6 => 1, diff --git a/src/support/serde.rs b/src/support/serde.rs index c06160c..de5627b 100644 --- a/src/support/serde.rs +++ b/src/support/serde.rs @@ -100,7 +100,7 @@ impl<'de, const BITS: usize, const LIMBS: usize> Deserialize<'de> for Bits; -impl<'de, const BITS: usize, const LIMBS: usize> Visitor<'de> for HrVisitor { +impl Visitor<'_> for HrVisitor { type Value = Uint; fn expecting(&self, formatter: &mut Formatter) -> FmtResult { @@ -136,7 +136,7 @@ impl<'de, const BITS: usize, const LIMBS: usize> Visitor<'de> for HrVisitor; -impl<'de, const BITS: usize, const LIMBS: usize> Visitor<'de> for ByteVisitor { +impl Visitor<'_> for ByteVisitor { type Value = Uint; fn expecting(&self, formatter: &mut Formatter) -> FmtResult { diff --git a/src/support/sqlx.rs b/src/support/sqlx.rs index c113f87..de2f029 100644 --- a/src/support/sqlx.rs +++ b/src/support/sqlx.rs @@ -5,9 +5,8 @@ #![cfg(feature = "sqlx")] #![cfg_attr(docsrs, doc(cfg(feature = "sqlx")))] -use crate::Uint; use sqlx_core::{ - database::{Database, HasArguments, HasValueRef}, + database::Database, decode::Decode, encode::{Encode, IsNull}, error::BoxDynError, @@ -15,6 +14,8 @@ use sqlx_core::{ }; use thiserror::Error; +use crate::Uint; + #[derive(Error, Debug)] pub enum DecodeError { #[error("Value too large for target type")] @@ -38,7 +39,10 @@ impl<'a, const BITS: usize, const LIMBS: usize, DB: Database> Encode<'a, DB> for where Vec: Encode<'a, DB>, { - fn encode_by_ref(&self, buf: &mut >::ArgumentBuffer) -> IsNull { + fn encode_by_ref( + &self, + buf: &mut ::ArgumentBuffer<'a>, + ) -> Result { self.to_be_bytes_vec().encode_by_ref(buf) } } @@ -47,7 +51,7 @@ impl<'a, const BITS: usize, const LIMBS: usize, DB: Database> Decode<'a, DB> for where Vec: Decode<'a, DB>, { - fn decode(value: >::ValueRef) -> Result { + fn decode(value: ::ValueRef<'a>) -> Result { let bytes = Vec::::decode(value)?; Self::try_from_be_slice(bytes.as_slice()).ok_or_else(|| DecodeError::Overflow.into()) }