From b39f3e03a5c816d7fdfe250f93d9495331daf35d Mon Sep 17 00:00:00 2001 From: HatemMn <19950216+HatemMn@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:23:28 +0100 Subject: [PATCH] fix: clippy --- Cargo.lock | 2 +- Cargo.toml | 1 + crate/client/src/rest_client.rs | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73f6f6b..fff0084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -830,7 +830,7 @@ dependencies = [ [[package]] name = "cosmian_findex" version = "7.0.0" -source = "git+https://www.github.com/Cosmian/findex?branch=feat%2Fadd-encoding-test#43ad7378168a80a56e390bd991b970f6a35a0e96" +source = "git+https://www.github.com/Cosmian/findex?branch=feat%2Fadd-encoding-test#f9f465dfc91a7ce60404c30f9c3596af8c1783f6" dependencies = [ "aes", "rand", diff --git a/Cargo.toml b/Cargo.toml index a6cbe7d..0abf698 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ cosmian_config_utils = { git = "https://www.github.com/Cosmian/http_client_serve cosmian_crypto_core = { version = "9.3.0", default-features = false } cosmian_findex = { git = "https://www.github.com/Cosmian/findex", branch = "feat/add-encoding-test", features = [ "redis-mem", + "test-utils", ] } cosmian_http_client = { git = "https://www.github.com/Cosmian/http_client_server", branch = "develop" } cosmian_logger = { git = "https://www.github.com/Cosmian/http_client_server", branch = "develop" } diff --git a/crate/client/src/rest_client.rs b/crate/client/src/rest_client.rs index 4675e60..1a4acbc 100644 --- a/crate/client/src/rest_client.rs +++ b/crate/client/src/rest_client.rs @@ -111,13 +111,16 @@ impl MemoryADT for FindexRestClient { type Word = [u8; WORD_LENGTH]; type Error = FindexClientError; + #[allow(clippy::renamed_function_params)] // original name (a) is less clear async fn batch_read( &self, addresses: Vec, ) -> Result>, FindexClientError> { - let index_id = self.index_id.expect( - "Unexpected error : this function should never be called while from base instance", - ); + let index_id = self.index_id.ok_or_else(|| { + FindexClientError::UnexpectedError( + "This function should never be called while from base instance".to_owned(), + ) + })?; let endpoint = format!("/indexes/{index_id}/batch_read"); let server_url = format!("{}{}", self.http_client.server_url, endpoint); trace!( @@ -157,9 +160,11 @@ impl MemoryADT for FindexRestClient { guard: (Self::Address, Option), tasks: Vec<(Self::Address, Self::Word)>, ) -> Result, FindexClientError> { - let index_id = self.index_id.expect( - "Unexpected error : this function should never be called while from base instance", - ); + let index_id = self.index_id.ok_or_else(|| { + FindexClientError::UnexpectedError( + "This function should never be called while from base instance".to_owned(), + ) + })?; let endpoint = format!("/indexes/{index_id}/guarded_write"); let server_url = format!("{}{}", self.http_client.server_url, &endpoint); trace!( @@ -207,6 +212,8 @@ impl MemoryADT for FindexRestClient { &server_url, result_word ); + #[allow(clippy::indexing_slicing)] + // we are sure that the length is 1, escaping this lint causes enormous boilerplate that is not necessary Ok(result_word[0]) } }