diff --git a/cassandra-protocol/Cargo.toml b/cassandra-protocol/Cargo.toml index 81967be..e33599f 100644 --- a/cassandra-protocol/Cargo.toml +++ b/cassandra-protocol/Cargo.toml @@ -16,7 +16,6 @@ e2e-tests = [] [dependencies] arc-swap.workspace = true -arrayref = "0.3.7" bitflags = "2.5.0" chrono = { version = "0.4.31", default_features = false, features = ["std"] } crc32fast = "1.4.0" @@ -25,10 +24,10 @@ derive_more.workspace = true float_eq = "1.0.1" integer-encoding = "4.0.0" itertools.workspace = true -num = "0.4.1" +num-bigint = "0.4.1" lz4_flex = "0.11.1" snap = "1.1.0" thiserror.workspace = true -time = { version = "0.3.29", features = ["std", "macros"] } +time = { version = "0.3.29", features = ["macros"] } uuid.workspace = true bytes.workspace = true diff --git a/cassandra-protocol/src/frame/traits.rs b/cassandra-protocol/src/frame/traits.rs index 75d7483..64e9a08 100644 --- a/cassandra-protocol/src/frame/traits.rs +++ b/cassandra-protocol/src/frame/traits.rs @@ -1,7 +1,7 @@ use crate::error; use crate::frame::Version; use crate::query; -use num::BigInt; +use num_bigint::BigInt; use std::io::{Cursor, Write}; /// Trait that should be implemented by all types that wish to be serialized to a buffer. diff --git a/cassandra-protocol/src/types.rs b/cassandra-protocol/src/types.rs index c499a6a..19e4797 100644 --- a/cassandra-protocol/src/types.rs +++ b/cassandra-protocol/src/types.rs @@ -497,7 +497,7 @@ pub fn cursor_next_value_ref<'a>( mod tests { use super::*; use crate::frame::traits::FromCursor; - use num::BigInt; + use num_bigint::BigInt; use std::io::Cursor; fn from_i_bytes(bytes: &[u8]) -> i64 { diff --git a/cassandra-protocol/src/types/cassandra_type.rs b/cassandra-protocol/src/types/cassandra_type.rs index b939699..5dc71ee 100644 --- a/cassandra-protocol/src/types/cassandra_type.rs +++ b/cassandra-protocol/src/types/cassandra_type.rs @@ -1,4 +1,4 @@ -use num::BigInt; +use num_bigint::BigInt; use std::collections::HashMap; use std::net::IpAddr; diff --git a/cassandra-protocol/src/types/data_serialization_types.rs b/cassandra-protocol/src/types/data_serialization_types.rs index 475d0e3..d948ed8 100644 --- a/cassandra-protocol/src/types/data_serialization_types.rs +++ b/cassandra-protocol/src/types/data_serialization_types.rs @@ -1,6 +1,6 @@ -use arrayref::array_ref; use integer_encoding::VarInt; -use num::BigInt; +use num_bigint::BigInt; +use std::convert::TryInto; use std::io; use std::net; use std::string::FromUtf8Error; @@ -12,7 +12,7 @@ use crate::error; use crate::frame::{FromCursor, Version}; use crate::types::{ try_f32_from_bytes, try_f64_from_bytes, try_i16_from_bytes, try_i32_from_bytes, - try_i64_from_bytes, u16_from_bytes, CBytes, CInt, INT_LEN, + try_i64_from_bytes, CBytes, CInt, INT_LEN, }; // https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec#L813 @@ -105,20 +105,14 @@ pub fn decode_float(bytes: &[u8]) -> Result { pub fn decode_inet(bytes: &[u8]) -> Result { match bytes.len() { // v4 - 4 => Ok(net::IpAddr::V4(net::Ipv4Addr::new( - bytes[0], bytes[1], bytes[2], bytes[3], - ))), + 4 => { + let array: [u8; 4] = bytes[0..4].try_into().unwrap(); + Ok(net::IpAddr::V4(net::Ipv4Addr::from(array))) + } // v6 16 => { - let a = u16_from_bytes(*array_ref!(bytes, 0, 2)); - let b = u16_from_bytes(*array_ref!(bytes, 2, 2)); - let c = u16_from_bytes(*array_ref!(bytes, 4, 2)); - let d = u16_from_bytes(*array_ref!(bytes, 6, 2)); - let e = u16_from_bytes(*array_ref!(bytes, 8, 2)); - let f = u16_from_bytes(*array_ref!(bytes, 10, 2)); - let g = u16_from_bytes(*array_ref!(bytes, 12, 2)); - let h = u16_from_bytes(*array_ref!(bytes, 14, 2)); - Ok(net::IpAddr::V6(net::Ipv6Addr::new(a, b, c, d, e, f, g, h))) + let array: [u8; 16] = bytes[0..16].try_into().unwrap(); + Ok(net::IpAddr::V6(net::Ipv6Addr::from(array))) } _ => Err(io::Error::new( io::ErrorKind::Other, diff --git a/cassandra-protocol/src/types/decimal.rs b/cassandra-protocol/src/types/decimal.rs index 2cbe23e..cf15282 100644 --- a/cassandra-protocol/src/types/decimal.rs +++ b/cassandra-protocol/src/types/decimal.rs @@ -1,6 +1,6 @@ use derive_more::Constructor; use float_eq::*; -use num::BigInt; +use num_bigint::BigInt; use std::io::Cursor; use crate::frame::{Serialize, Version}; diff --git a/cassandra-protocol/src/types/list.rs b/cassandra-protocol/src/types/list.rs index 7fa7832..adb75ff 100644 --- a/cassandra-protocol/src/types/list.rs +++ b/cassandra-protocol/src/types/list.rs @@ -1,5 +1,5 @@ use derive_more::Constructor; -use num::BigInt; +use num_bigint::BigInt; use std::net::IpAddr; use uuid::Uuid; diff --git a/cassandra-protocol/src/types/map.rs b/cassandra-protocol/src/types/map.rs index 4c31023..07f3c28 100644 --- a/cassandra-protocol/src/types/map.rs +++ b/cassandra-protocol/src/types/map.rs @@ -13,7 +13,7 @@ use crate::types::list::List; use crate::types::tuple::Tuple; use crate::types::udt::Udt; use crate::types::{AsRust, AsRustType, CBytes}; -use num::BigInt; +use num_bigint::BigInt; #[derive(Debug)] pub struct Map { diff --git a/cassandra-protocol/src/types/rows.rs b/cassandra-protocol/src/types/rows.rs index 5a268a3..8d2d665 100644 --- a/cassandra-protocol/src/types/rows.rs +++ b/cassandra-protocol/src/types/rows.rs @@ -19,7 +19,7 @@ use crate::types::map::Map; use crate::types::tuple::Tuple; use crate::types::udt::Udt; use crate::types::{ByIndex, ByName, CBytes, IntoRustByIndex, IntoRustByName}; -use num::BigInt; +use num_bigint::BigInt; #[derive(Clone, Debug)] pub struct Row { diff --git a/cassandra-protocol/src/types/tuple.rs b/cassandra-protocol/src/types/tuple.rs index b8fd2f1..376b55b 100644 --- a/cassandra-protocol/src/types/tuple.rs +++ b/cassandra-protocol/src/types/tuple.rs @@ -1,5 +1,5 @@ use chrono::prelude::*; -use num::BigInt; +use num_bigint::BigInt; use std::hash::{Hash, Hasher}; use std::net::IpAddr; use time::PrimitiveDateTime; diff --git a/cassandra-protocol/src/types/udt.rs b/cassandra-protocol/src/types/udt.rs index bf87e18..88aa80f 100644 --- a/cassandra-protocol/src/types/udt.rs +++ b/cassandra-protocol/src/types/udt.rs @@ -16,7 +16,7 @@ use crate::types::list::List; use crate::types::map::Map; use crate::types::tuple::Tuple; use crate::types::{ByName, CBytes, IntoRustByName}; -use num::BigInt; +use num_bigint::BigInt; #[derive(Clone, Debug)] pub struct Udt { diff --git a/cassandra-protocol/src/types/value.rs b/cassandra-protocol/src/types/value.rs index 94a8e40..0bc399b 100644 --- a/cassandra-protocol/src/types/value.rs +++ b/cassandra-protocol/src/types/value.rs @@ -7,7 +7,7 @@ use std::net::IpAddr; use std::num::{NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8}; use chrono::prelude::*; -use num::BigInt; +use num_bigint::BigInt; use time::PrimitiveDateTime; use uuid::Uuid;