Skip to content

Commit

Permalink
feat: change implems and reduce pointless implems
Browse files Browse the repository at this point in the history
  • Loading branch information
HatemMn committed Jan 17, 2025
1 parent 465c0fb commit e79b267
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 43 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
name = "cosmian_findex"
version = "7.0.0"
authors = [
"Chloé Hébant <[email protected]>",
"Bruno Grieder <[email protected]>",
"Célia Corsin <[email protected]>",
"Chloé Hébant <[email protected]>",
"Emmanuel Coste <[email protected]>",
"Hatem Mnaouer <[email protected]>",
"Théophile Brézot <[email protected]>",
]
categories = ["cosmian::crypto"]
Expand Down
12 changes: 0 additions & 12 deletions src/address.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::ops::{Add, Deref, DerefMut};

use rand_core::CryptoRngCore;
#[cfg(feature = "redis-mem")]
use redis::ToRedisArgs;

// NOTE: a more efficient implementation of the address could be a big-int.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand All @@ -20,16 +18,6 @@ impl<const LENGTH: usize> From<Address<LENGTH>> for [u8; LENGTH] {
}
}

#[cfg(feature = "redis-mem")]
impl<const LENGTH: usize> ToRedisArgs for Address<LENGTH> {
fn write_redis_args<W>(&self, out: &mut W)
where
W: ?Sized + redis::RedisWrite,
{
out.write_arg(&**self)
}
}

impl<const LENGTH: usize> Deref for Address<LENGTH> {
type Target = [u8; LENGTH];

Expand Down
26 changes: 1 addition & 25 deletions src/adt/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ use crate::MemoryADT;
/// * `T::Address: Debug + PartialEq + From<[u8; 16]> + Send`
/// * `T::Word: Debug + PartialEq + From<[u8; 16]> + Send`
/// * `T::Error: std::error::Error + Send`
///
/// # Examples
///
/// ```no_run
/// # let memory = // your memory implementation
/// # let seed = [0u8; 32];
/// # test_single_write_and_read(&memory, seed).await;
/// ```
pub async fn test_single_write_and_read<T>(memory: &T, seed: [u8; 32])
where
T: MemoryADT + Send + Sync,
Expand Down Expand Up @@ -101,14 +93,6 @@ where
/// * `T::Address: Debug + PartialEq + From<[u8; 16]> + Send`
/// * `T::Word: Debug + PartialEq + From<[u8; 16]> + Send`
/// * `T::Error: std::error::Error + Send`
///
/// # Examples
///
/// ```no_run
/// # let memory = // your memory implementation
/// # let seed = [0u8; 32];
/// # test_wrong_guard(&memory, seed).await;
/// ```
pub async fn test_wrong_guard<T>(memory: &T, seed: [u8; 32])
where
T: MemoryADT + Send + Sync,
Expand Down Expand Up @@ -179,15 +163,7 @@ where
/// * `MemoryADT + Send + Sync + 'static + Clone`
/// * `T::Address: Debug + PartialEq + From<[u8; 16]> + Send`
/// * `T::Word: Debug + PartialEq + From<[u8; 16]> + Into<[u8; 16]> + Send + Clone + Default`
/// * `T::Error: std::error::Error`
///
/// # Examples
///
/// ```no_run
/// # let memory = // your memory implementation
/// # let seed = [0u8; 32];
/// # test_guarded_write_concurrent(&memory, seed).await;
/// ```
/// * `T::Error: std::error::
pub async fn test_guarded_write_concurrent<T>(memory: &T, seed: [u8; 32])
where
T: MemoryADT + Send + Sync + 'static + Clone,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use secret::Secret;
pub use value::Value;

#[cfg(feature = "redis-mem")]
pub use memory::redis_store::RedisMemory;
pub use memory::redis_store::{MemoryError, RedisMemory};

#[cfg(any(feature = "redis-mem", feature = "bench"))]
pub use encoding::{WORD_LENGTH, dummy_decode, dummy_encode};
Expand Down
8 changes: 4 additions & 4 deletions src/memory/redis_store.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fmt, marker::PhantomData};

use redis::{AsyncCommands, RedisError, aio::ConnectionManager};
use redis::{RedisError, aio::ConnectionManager};

use crate::{ADDRESS_LENGTH, Address, MemoryADT};

Expand Down Expand Up @@ -102,9 +102,9 @@ impl<const WORD_LENGTH: usize> MemoryADT
&self,
addresses: Vec<Self::Address>,
) -> Result<Vec<Option<Self::Word>>, Self::Error> {
self.manager
.clone()
.mget(addresses)
let mut cmd = redis::cmd("MGET");
let cmd = addresses.iter().fold(&mut cmd, |c, a| c.arg(&**a));
cmd.query_async(&mut self.manager.clone())
.await
.map_err(Self::Error::from)
}
Expand Down

0 comments on commit e79b267

Please sign in to comment.