From 4a46bd4f85cc7e78fa60cb2159e96a430909df55 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Thu, 20 Jun 2024 10:08:33 +0300 Subject: [PATCH] update rust new version to 1.79 --- .github/workflows/publish-crate.yml | 2 +- .github/workflows/rust-tests.yml | 2 +- Cargo.lock | 2 +- ydb/src/credentials.rs | 20 ++++++++++++++++--- .../raw_table_service/value/value_ydb.rs | 2 +- ydb/src/session_pool.rs | 8 -------- ydb/src/types.rs | 2 +- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish-crate.yml b/.github/workflows/publish-crate.yml index 1cf9f106..0309a38e 100644 --- a/.github/workflows/publish-crate.yml +++ b/.github/workflows/publish-crate.yml @@ -1,7 +1,7 @@ name: Publish rust crate to crates.io env: CARGO_TERM_COLOR: always - RUST_VERSION: 1.78.0 + RUST_VERSION: 1.79.0 CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse on: diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index 3c4dad5f..9db5c54e 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -12,7 +12,7 @@ env: CARGO_TERM_COLOR: always CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse RUST_VERSION_OLD: "1.60.0" - RUST_VERSION_NEW: "1.78.0" + RUST_VERSION_NEW: "1.79.0" jobs: tests: diff --git a/Cargo.lock b/Cargo.lock index 41e2338f..60f6665e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2550,7 +2550,7 @@ dependencies = [ [[package]] name = "ydb" -version = "0.9.1" +version = "0.9.2" dependencies = [ "async-trait", "async_once", diff --git a/ydb/src/credentials.rs b/ydb/src/credentials.rs index 48da4c5e..8a9db732 100644 --- a/ydb/src/credentials.rs +++ b/ydb/src/credentials.rs @@ -66,6 +66,8 @@ impl MetadataUrlCredentials { } } + + /// Create GCEMetadata with custom url (may need for debug or spec infrastructure with non standard metadata) /// /// Example: @@ -84,6 +86,12 @@ impl MetadataUrlCredentials { } } +impl Default for MetadataUrlCredentials { + fn default() -> Self { + Self::new() + } +} + impl Credentials for MetadataUrlCredentials { fn create_token(&self) -> YdbResult { self.inner.create_token() @@ -102,6 +110,12 @@ impl AnonymousCredentials { } } +impl Default for AnonymousCredentials { + fn default() -> Self { + Self::new() + } +} + impl Credentials for AnonymousCredentials { fn create_token(&self) -> YdbResult { self.inner.create_token() @@ -152,7 +166,7 @@ fn get_credentials_from_env() -> YdbResult> { return Ok(Box::new(AccessTokenCredentials::from(token))); } - return Ok(Box::new(MetadataUrlCredentials::new())); + Ok(Box::new(MetadataUrlCredentials::new())) } /// Credentials with static token without renewing @@ -409,8 +423,8 @@ impl ServiceAccountCredentials { let duration = time - chrono::Utc::now(); let seconds = (0.1 * duration.num_seconds() as f64) as u64; trace!("renew in: {}", seconds); - let instant = Instant::now() + Duration::from_secs(seconds); - instant + + Instant::now() + Duration::from_secs(seconds) } } diff --git a/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs b/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs index aef96e85..7749ad33 100644 --- a/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs +++ b/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs @@ -247,7 +247,7 @@ impl TryFrom for Value { let int_val = merge_parts(high, low) as i128; let value = - decimal_rs::Decimal::from_parts(int_val.abs() as u128, t.scale, int_val < 0) + decimal_rs::Decimal::from_parts(int_val.unsigned_abs(), t.scale, int_val < 0) .map_err(|e| RawError::decode_error(e.to_string()))?; return Ok(Value::Decimal(value)); } diff --git a/ydb/src/session_pool.rs b/ydb/src/session_pool.rs index 3718fc9a..b7f499d2 100644 --- a/ydb/src/session_pool.rs +++ b/ydb/src/session_pool.rs @@ -15,7 +15,6 @@ const DEFAULT_SIZE: usize = 1000; #[async_trait] pub(crate) trait SessionFabric: Send + Sync { async fn create_session(&self, timeouts: TimeoutSettings) -> YdbResult; - fn clone_box(&self) -> Box; } #[async_trait] @@ -29,9 +28,6 @@ impl SessionFabric for GrpcConnectionManager { let session = Session::new(session_res.id, self.clone(), TimeoutSettings::default()); return Ok(session); } - fn clone_box(&self) -> Box { - Box::new(self.clone()) - } } type IdleSessions = Arc>>; @@ -179,10 +175,6 @@ mod test { timeouts, )) } - - fn clone_box(&self) -> Box { - Box::new(SessionClientMock {}) - } } struct TableChannelPoolMock {} diff --git a/ydb/src/types.rs b/ydb/src/types.rs index c803fc27..4db9b8fd 100644 --- a/ydb/src/types.rs +++ b/ydb/src/types.rs @@ -416,7 +416,7 @@ impl Value { r#type: Some(ydb_proto::Type { r#type: Some(ydb_proto::r#type::Type::DecimalType( ydb_proto::DecimalType { - precision: val.precision().try_into()?, + precision: val.precision().into(), scale: val.scale().try_into()?, }, )),