Skip to content

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
HatemMn committed Dec 27, 2024
1 parent 34c0d1f commit e535dd7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{collections::HashSet, time::Duration};

use cosmian_findex::{
Findex, InMemory, IndexADT, MemoryADT, Op, Secret, WORD_LENGTH, dummy_decode, dummy_encode,
dummy_decode, dummy_encode, Findex, InMemory, IndexADT, MemoryADT, Op, Secret, WORD_LENGTH,
};
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use futures::{executor::block_on, future::join_all};
use lazy_static::lazy_static;
use rand_chacha::ChaChaRng;
Expand Down
2 changes: 1 addition & 1 deletion examples/insert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use cosmian_findex::{Findex, InMemory, IndexADT, Secret, Value, dummy_decode, dummy_encode};
use cosmian_findex::{dummy_decode, dummy_encode, Findex, InMemory, IndexADT, Secret, Value};
use futures::executor::block_on;
use rand_chacha::ChaChaRng;
use rand_core::{CryptoRngCore, SeedableRng};
Expand Down
36 changes: 21 additions & 15 deletions src/findex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{
use tiny_keccak::{Hasher, Sha3};

use crate::{
ADDRESS_LENGTH, Address, IndexADT, KEY_LENGTH, MemoryADT, Secret, adt::VectorADT, encoding::Op,
encryption_layer::MemoryEncryptionLayer, error::Error, ovec::IVec,
adt::VectorADT, encoding::Op, encryption_layer::MemoryEncryptionLayer, error::Error,
ovec::IVec, Address, IndexADT, MemoryADT, Secret, ADDRESS_LENGTH, KEY_LENGTH,
};

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -48,11 +48,14 @@ pub struct Findex<
}

impl<
const WORD_LENGTH: usize,
Value: Send + Sync + Hash + Eq,
TryFromError: std::error::Error,
Memory: Send + Sync + Clone + MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> Findex<WORD_LENGTH, Value, TryFromError, Memory>
const WORD_LENGTH: usize,
Value: Send + Sync + Hash + Eq,
TryFromError: std::error::Error,
Memory: Send
+ Sync
+ Clone
+ MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> Findex<WORD_LENGTH, Value, TryFromError, Memory>
where
for<'z> Value: TryFrom<&'z [u8], Error = TryFromError> + AsRef<[u8]>,
Vec<u8>: From<Value>,
Expand Down Expand Up @@ -167,13 +170,16 @@ where
}

impl<
const WORD_LENGTH: usize,
Keyword: Send + Sync + Hash + PartialEq + Eq + AsRef<[u8]>,
Value: Send + Sync + Hash + PartialEq + Eq,
TryFromError: std::error::Error,
Memory: Send + Sync + Clone + MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> IndexADT<Keyword, Value> for Findex<WORD_LENGTH, Value, TryFromError, Memory>
// TODO(hatem): ajouter un paramètre
const WORD_LENGTH: usize,
Keyword: Send + Sync + Hash + PartialEq + Eq + AsRef<[u8]>,
Value: Send + Sync + Hash + PartialEq + Eq,
TryFromError: std::error::Error,
Memory: Send
+ Sync
+ Clone
+ MemoryADT<Address = Address<ADDRESS_LENGTH>, Word = [u8; WORD_LENGTH]>,
> IndexADT<Keyword, Value> for Findex<WORD_LENGTH, Value, TryFromError, Memory>
// TODO(hatem): ajouter un paramètre
where
for<'z> Value: TryFrom<&'z [u8], Error = TryFromError> + AsRef<[u8]>,
Vec<u8>: From<Value>,
Expand Down Expand Up @@ -228,11 +234,11 @@ mod tests {
use rand_core::SeedableRng;

use crate::{
ADDRESS_LENGTH, Findex, IndexADT, Value,
address::Address,
encoding::{dummy_decode, dummy_encode},
memory::in_memory::InMemory,
secret::Secret,
Findex, IndexADT, Value, ADDRESS_LENGTH,
};

const WORD_LENGTH: usize = 16;
Expand Down
28 changes: 14 additions & 14 deletions src/ovec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::{fmt::Debug, hash::Hash, ops::Add};

use crate::{MemoryADT, adt::VectorADT, error::Error};
use crate::{adt::VectorADT, error::Error, MemoryADT};

/// Headers contain a counter of the number of values stored in the vector.
// TODO: header could store metadata (e.g. sparsity budget)
Expand Down Expand Up @@ -79,10 +79,10 @@ pub(crate) struct IVec<
}

impl<
const WORD_LENGTH: usize,
Address: Clone,
Memory: Clone + MemoryADT<Address = Address, Word = [u8; WORD_LENGTH]>,
> Clone for IVec<WORD_LENGTH, Memory>
const WORD_LENGTH: usize,
Address: Clone,
Memory: Clone + MemoryADT<Address = Address, Word = [u8; WORD_LENGTH]>,
> Clone for IVec<WORD_LENGTH, Memory>
{
fn clone(&self) -> Self {
Self {
Expand All @@ -94,10 +94,10 @@ impl<
}

impl<
const WORD_LENGTH: usize,
Address: Hash + Eq + Debug + Clone + Add<u64, Output = Address>,
Memory: Clone + MemoryADT<Address = Address, Word = [u8; WORD_LENGTH]>,
> IVec<WORD_LENGTH, Memory>
const WORD_LENGTH: usize,
Address: Hash + Eq + Debug + Clone + Add<u64, Output = Address>,
Memory: Clone + MemoryADT<Address = Address, Word = [u8; WORD_LENGTH]>,
> IVec<WORD_LENGTH, Memory>
{
/// (Lazily) instantiates a new vector at this address in this memory: no value is written
/// before the first push.
Expand All @@ -107,10 +107,10 @@ impl<
}

impl<
const WORD_LENGTH: usize,
Address: Send + Sync + Hash + Eq + Debug + Clone + Add<u64, Output = Address>,
Memory: Send + Sync + Clone + MemoryADT<Address = Address, Word = [u8; WORD_LENGTH]>,
> VectorADT for IVec<WORD_LENGTH, Memory>
const WORD_LENGTH: usize,
Address: Send + Sync + Hash + Eq + Debug + Clone + Add<u64, Output = Address>,
Memory: Send + Sync + Clone + MemoryADT<Address = Address, Word = [u8; WORD_LENGTH]>,
> VectorADT for IVec<WORD_LENGTH, Memory>
where
Memory::Error: Send + Sync,
{
Expand Down Expand Up @@ -215,13 +215,13 @@ mod tests {
use rand_core::SeedableRng;

use crate::{
ADDRESS_LENGTH,
address::Address,
adt::tests::{test_vector_concurrent, test_vector_sequential},
encryption_layer::MemoryEncryptionLayer,
memory::in_memory::InMemory,
ovec::IVec,
secret::Secret,
ADDRESS_LENGTH,
};

const WORD_LENGTH: usize = 16;
Expand Down

0 comments on commit e535dd7

Please sign in to comment.