From c33917588f4c73ef47f05d19eb425f9c76eca18c Mon Sep 17 00:00:00 2001 From: muzarski Date: Thu, 22 Feb 2024 16:33:38 +0100 Subject: [PATCH] cargo: rename `chrono` feature to `chrono-04` --- .github/workflows/rust.yml | 2 +- examples/Cargo.toml | 2 +- scylla-cql/Cargo.toml | 6 ++-- scylla-cql/src/frame/response/cql_to_rust.rs | 24 ++++++++-------- scylla-cql/src/frame/response/result.rs | 24 ++++++++-------- scylla-cql/src/frame/value.rs | 30 ++++++++++---------- scylla-cql/src/frame/value_tests.rs | 12 ++++---- scylla-cql/src/types/serialize/value.rs | 12 ++++---- scylla/Cargo.toml | 4 +-- scylla/src/transport/cql_types_test.rs | 6 ++-- 10 files changed, 61 insertions(+), 61 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index acf96dc524..2ddb711b0b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -37,7 +37,7 @@ jobs: - name: Cargo check with secret feature run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "secrecy-08" - name: Cargo check with chrono feature - run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "chrono" + run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "chrono-04" - name: Cargo check with time feature run: cargo check --all-targets --manifest-path "scylla/Cargo.toml" --features "time-03" - name: Cargo check with num-bigint-03 feature diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 265dca2dbe..b29b1608f9 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -10,7 +10,7 @@ futures = "0.3.6" openssl = "0.10.32" rustyline = "9" rustyline-derive = "0.6" -scylla = {path = "../scylla", features = ["ssl", "cloud", "chrono", "time-03", "num-bigint-03", "num-bigint-04", "bigdecimal-04"]} +scylla = {path = "../scylla", features = ["ssl", "cloud", "chrono-04", "time-03", "num-bigint-03", "num-bigint-04", "bigdecimal-04"]} tokio = {version = "1.1.0", features = ["full"]} tracing = "0.1.25" tracing-subscriber = { version = "0.3.14", features = ["env-filter"] } diff --git a/scylla-cql/Cargo.toml b/scylla-cql/Cargo.toml index 370f5323bd..de217bd549 100644 --- a/scylla-cql/Cargo.toml +++ b/scylla-cql/Cargo.toml @@ -21,7 +21,7 @@ thiserror = "1.0" num-bigint-03 = { package = "num-bigint", version = "0.3", optional = true } num-bigint-04 = { package = "num-bigint", version = "0.4", optional = true } bigdecimal-04 = { package = "bigdecimal", version = "0.4", optional = true } -chrono = { version = "0.4", default-features = false, optional = true } +chrono-04 = { package = "chrono", version = "0.4", default-features = false, optional = true } lz4_flex = { version = "0.11.1" } async-trait = "0.1.57" serde = { version = "1.0", features = ["derive"], optional = true } @@ -39,8 +39,8 @@ harness = false [features] secrecy-08 = ["dep:secrecy-08"] time-03 = ["dep:time-03"] -chrono = ["dep:chrono"] +chrono-04 = ["dep:chrono-04"] num-bigint-03 = ["dep:num-bigint-03"] num-bigint-04 = ["dep:num-bigint-04"] bigdecimal-04 = ["dep:bigdecimal-04"] -full-serialization = ["chrono", "time-03", "secrecy-08", "num-bigint-03", "num-bigint-04", "bigdecimal-04"] +full-serialization = ["chrono-04", "time-03", "secrecy-08", "num-bigint-03", "num-bigint-04", "bigdecimal-04"] diff --git a/scylla-cql/src/frame/response/cql_to_rust.rs b/scylla-cql/src/frame/response/cql_to_rust.rs index 525eb4d1ee..8489b8bf97 100644 --- a/scylla-cql/src/frame/response/cql_to_rust.rs +++ b/scylla-cql/src/frame/response/cql_to_rust.rs @@ -8,8 +8,8 @@ use std::net::IpAddr; use thiserror::Error; use uuid::Uuid; -#[cfg(feature = "chrono")] -use chrono::{DateTime, NaiveDate, NaiveTime, Utc}; +#[cfg(feature = "chrono-04")] +use chrono_04::{DateTime, NaiveDate, NaiveTime, Utc}; #[cfg(feature = "secrecy-08")] use secrecy_08::{Secret, Zeroize}; @@ -178,7 +178,7 @@ impl FromCqlVal for bigdecimal_04::BigDecimal { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl FromCqlVal for NaiveDate { fn from_cql(cql_val: CqlValue) -> Result { match cql_val { @@ -198,7 +198,7 @@ impl FromCqlVal for time_03::Date { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl FromCqlVal for NaiveTime { fn from_cql(cql_val: CqlValue) -> Result { match cql_val { @@ -218,7 +218,7 @@ impl FromCqlVal for time_03::Time { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl FromCqlVal for DateTime { fn from_cql(cql_val: CqlValue) -> Result { cql_val @@ -526,10 +526,10 @@ mod tests { assert_eq!(Ok(counter), Counter::from_cql(CqlValue::Counter(counter))); } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] #[test] fn naive_date_from_cql() { - use chrono::NaiveDate; + use chrono_04::NaiveDate; let unix_epoch: CqlValue = CqlValue::Date(CqlDate(2_u32.pow(31))); assert_eq!( @@ -634,10 +634,10 @@ mod tests { assert_eq!(time_ns, CqlTime::from_cql(cql_value).unwrap().0); } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] #[test] fn naive_time_from_cql() { - use chrono::NaiveTime; + use chrono_04::NaiveTime; // Midnight let midnight = CqlValue::Time(CqlTime(0)); @@ -661,7 +661,7 @@ mod tests { NaiveTime::from_cql(late_night) ); - // Bad values. Since value is out of `chrono::NaiveTime` range, it should return `BadVal` error + // Bad values. Since value is out of `chrono_04::NaiveTime` range, it should return `BadVal` error let bad_time1 = CqlValue::Time(CqlTime(-1)); assert_eq!(Err(FromCqlValError::BadVal), NaiveTime::from_cql(bad_time1)); let bad_time2 = CqlValue::Time(CqlTime(i64::MAX)); @@ -734,10 +734,10 @@ mod tests { ); } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] #[test] fn datetime_from_cql() { - use chrono::{DateTime, NaiveDate, Utc}; + use chrono_04::{DateTime, NaiveDate, Utc}; let naivedatetime_utc = NaiveDate::from_ymd_opt(2022, 12, 31) .unwrap() .and_hms_opt(2, 0, 0) diff --git a/scylla-cql/src/frame/response/result.rs b/scylla-cql/src/frame/response/result.rs index 843df38cb5..8a40403d21 100644 --- a/scylla-cql/src/frame/response/result.rs +++ b/scylla-cql/src/frame/response/result.rs @@ -15,8 +15,8 @@ use std::{ }; use uuid::Uuid; -#[cfg(feature = "chrono")] -use chrono::{DateTime, NaiveDate, Utc}; +#[cfg(feature = "chrono-04")] +use chrono_04::{DateTime, NaiveDate, Utc}; #[derive(Debug)] pub struct SetKeyspace { @@ -156,7 +156,7 @@ impl CqlValue { } } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] pub fn as_naive_date(&self) -> Option { self.as_cql_date().and_then(|date| date.try_into().ok()) } @@ -173,7 +173,7 @@ impl CqlValue { } } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] pub fn as_datetime(&self) -> Option> { self.as_cql_timestamp().and_then(|ts| ts.try_into().ok()) } @@ -190,8 +190,8 @@ impl CqlValue { } } - #[cfg(feature = "chrono")] - pub fn as_naive_time(&self) -> Option { + #[cfg(feature = "chrono-04")] + pub fn as_naive_time(&self) -> Option { self.as_cql_time().and_then(|ts| ts.try_into().ok()) } @@ -1362,10 +1362,10 @@ mod tests { assert_eq!(date.as_cql_date(), Some(max_date)); } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] #[test] fn test_naive_date_from_cql() { - use chrono::NaiveDate; + use chrono_04::NaiveDate; // 2^31 when converted to NaiveDate is 1970-01-01 let unix_epoch = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap(); @@ -1485,10 +1485,10 @@ mod tests { } } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] #[test] fn test_naive_time_from_cql() { - use chrono::NaiveTime; + use chrono_04::NaiveTime; // 0 when converted to NaiveTime is 0:0:0.0 let midnight = NaiveTime::from_hms_nano_opt(0, 0, 0, 0).unwrap(); @@ -1577,10 +1577,10 @@ mod tests { } } - #[cfg(feature = "chrono")] + #[cfg(feature = "chrono-04")] #[test] fn test_datetime_from_cql() { - use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; + use chrono_04::{NaiveDate, NaiveDateTime, NaiveTime}; // 0 when converted to DateTime is 1970-01-01 0:00:00.00 let unix_epoch = NaiveDateTime::from_timestamp_opt(0, 0).unwrap().and_utc(); diff --git a/scylla-cql/src/frame/value.rs b/scylla-cql/src/frame/value.rs index 952e0f25a2..c6b064b032 100644 --- a/scylla-cql/src/frame/value.rs +++ b/scylla-cql/src/frame/value.rs @@ -9,8 +9,8 @@ use std::net::IpAddr; use thiserror::Error; use uuid::Uuid; -#[cfg(feature = "chrono")] -use chrono::{DateTime, NaiveDate, NaiveTime, TimeZone, Utc}; +#[cfg(feature = "chrono-04")] +use chrono_04::{DateTime, NaiveDate, NaiveTime, TimeZone, Utc}; use super::response::result::CqlValue; use super::types::vint_encode; @@ -467,7 +467,7 @@ pub struct CqlTimestamp(pub i64); #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct CqlTime(pub i64); -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl From for CqlDate { fn from(value: NaiveDate) -> Self { let unix_epoch = NaiveDate::from_yo_opt(1970, 1).unwrap(); @@ -480,7 +480,7 @@ impl From for CqlDate { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl TryInto for CqlDate { type Error = ValueOverflow; @@ -488,8 +488,8 @@ impl TryInto for CqlDate { let days_since_unix_epoch = self.0 as i64 - (1 << 31); // date_days is u32 then converted to i64 then we subtract 2^31; - // Max value is 2^31, min value is -2^31. Both values can safely fit in chrono::Duration, this call won't panic - let duration_since_unix_epoch = chrono::Duration::days(days_since_unix_epoch); + // Max value is 2^31, min value is -2^31. Both values can safely fit in chrono_04::Duration, this call won't panic + let duration_since_unix_epoch = chrono_04::Duration::days(days_since_unix_epoch); NaiveDate::from_yo_opt(1970, 1) .unwrap() @@ -498,32 +498,32 @@ impl TryInto for CqlDate { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl From> for CqlTimestamp { fn from(value: DateTime) -> Self { Self(value.timestamp_millis()) } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl TryInto> for CqlTimestamp { type Error = ValueOverflow; fn try_into(self) -> Result, Self::Error> { match Utc.timestamp_millis_opt(self.0) { - chrono::LocalResult::Single(datetime) => Ok(datetime), + chrono_04::LocalResult::Single(datetime) => Ok(datetime), _ => Err(ValueOverflow), } } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl TryFrom for CqlTime { type Error = ValueOverflow; fn try_from(value: NaiveTime) -> Result { let nanos = value - .signed_duration_since(chrono::NaiveTime::MIN) + .signed_duration_since(chrono_04::NaiveTime::MIN) .num_nanoseconds() .unwrap(); @@ -536,7 +536,7 @@ impl TryFrom for CqlTime { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl TryInto for CqlTime { type Error = ValueOverflow; @@ -1004,7 +1004,7 @@ impl Value for bigdecimal_04::BigDecimal { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl Value for NaiveDate { fn serialize(&self, buf: &mut Vec) -> Result<(), ValueTooBig> { CqlDate::from(*self).serialize(buf) @@ -1042,7 +1042,7 @@ impl Value for CqlTime { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl Value for DateTime { fn serialize(&self, buf: &mut Vec) -> Result<(), ValueTooBig> { CqlTimestamp::from(*self).serialize(buf) @@ -1056,7 +1056,7 @@ impl Value for time_03::OffsetDateTime { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl Value for NaiveTime { fn serialize(&self, buf: &mut Vec) -> Result<(), ValueTooBig> { CqlTime::try_from(*self) diff --git a/scylla-cql/src/frame/value_tests.rs b/scylla-cql/src/frame/value_tests.rs index a24f1807ad..ebedb43000 100644 --- a/scylla-cql/src/frame/value_tests.rs +++ b/scylla-cql/src/frame/value_tests.rs @@ -304,10 +304,10 @@ fn ipaddr_serialization() { ); } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] #[test] fn naive_date_serialization() { - use chrono::NaiveDate; + use chrono_04::NaiveDate; // 1970-01-31 is 2^31 let unix_epoch: NaiveDate = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap(); assert_eq!( @@ -410,10 +410,10 @@ fn cql_time_serialization() { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] #[test] fn naive_time_serialization() { - use chrono::NaiveTime; + use chrono_04::NaiveTime; let midnight_time: i64 = 0; let max_time: i64 = 24 * 60 * 60 * 1_000_000_000 - 1; @@ -490,10 +490,10 @@ fn cql_timestamp_serialization() { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] #[test] fn naive_date_time_serialization() { - use chrono::NaiveDateTime; + use chrono_04::NaiveDateTime; let test_cases = [ ( // Max time serialized without error diff --git a/scylla-cql/src/types/serialize/value.rs b/scylla-cql/src/types/serialize/value.rs index 50481ba30a..b6fb7334c5 100644 --- a/scylla-cql/src/types/serialize/value.rs +++ b/scylla-cql/src/types/serialize/value.rs @@ -9,8 +9,8 @@ use std::sync::Arc; use thiserror::Error; use uuid::Uuid; -#[cfg(feature = "chrono")] -use chrono::{DateTime, NaiveDate, NaiveTime, Utc}; +#[cfg(feature = "chrono-04")] +use chrono_04::{DateTime, NaiveDate, NaiveTime, Utc}; #[cfg(feature = "secrecy-08")] use secrecy_08::{ExposeSecret, Secret, Zeroize}; @@ -22,7 +22,7 @@ use crate::frame::value::{ MaybeUnset, Unset, Value, }; -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] use crate::frame::value::ValueOverflow; use super::writers::WrittenCellProof; @@ -160,21 +160,21 @@ impl SerializeCql for CqlTime { writer.set_value(me.0.to_be_bytes().as_slice()).unwrap() }); } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl SerializeCql for NaiveDate { impl_serialize_via_writer!(|me, typ, writer| { exact_type_check!(typ, Date); ::serialize(&(*me).into(), typ, writer)? }); } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl SerializeCql for DateTime { impl_serialize_via_writer!(|me, typ, writer| { exact_type_check!(typ, Timestamp); ::serialize(&(*me).into(), typ, writer)? }); } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] impl SerializeCql for NaiveTime { impl_serialize_via_writer!(|me, typ, writer| { exact_type_check!(typ, Time); diff --git a/scylla/Cargo.toml b/scylla/Cargo.toml index 85a676d5ca..791e2237a6 100644 --- a/scylla/Cargo.toml +++ b/scylla/Cargo.toml @@ -18,12 +18,12 @@ default = [] ssl = ["dep:tokio-openssl", "dep:openssl"] cloud = ["ssl", "scylla-cql/serde", "dep:serde_yaml", "dep:serde", "dep:url", "dep:base64"] secrecy-08 = ["scylla-cql/secrecy-08"] -chrono = ["scylla-cql/chrono"] +chrono-04 = ["scylla-cql/chrono-04"] time-03 = ["scylla-cql/time-03"] num-bigint-03 = ["scylla-cql/num-bigint-03"] num-bigint-04 = ["scylla-cql/num-bigint-04"] bigdecimal-04 = ["scylla-cql/bigdecimal-04"] -full-serialization = ["chrono", "time-03", "secrecy-08", "num-bigint-03", "num-bigint-04", "bigdecimal-04"] +full-serialization = ["chrono-04", "time-03", "secrecy-08", "num-bigint-03", "num-bigint-04", "bigdecimal-04"] [dependencies] scylla-macros = { version = "0.4.0", path = "../scylla-macros" } diff --git a/scylla/src/transport/cql_types_test.rs b/scylla/src/transport/cql_types_test.rs index 0fc34eec66..861424cc4a 100644 --- a/scylla/src/transport/cql_types_test.rs +++ b/scylla/src/transport/cql_types_test.rs @@ -290,7 +290,7 @@ async fn test_counter() { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] #[tokio::test] async fn test_naive_date() { use chrono::Datelike; @@ -626,7 +626,7 @@ async fn test_cql_time() { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] #[tokio::test] async fn test_naive_time() { use chrono::NaiveTime; @@ -853,7 +853,7 @@ async fn test_cql_timestamp() { } } -#[cfg(feature = "chrono")] +#[cfg(feature = "chrono-04")] #[tokio::test] async fn test_date_time() { use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};