From ec74847e63ee00110ef97137dbd4159d77be8ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 27 Oct 2024 19:58:58 +0100 Subject: [PATCH] Move the task struct to a dedicated module --- src/lib.rs | 22 ++-------------------- src/task.rs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 src/task.rs diff --git a/src/lib.rs b/src/lib.rs index ee1aa9b..68b94b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,23 +1,5 @@ pub mod algorithm; pub mod data; +pub mod task; -use pbkdf2::pbkdf2_hmac; -use sha2::Sha256; - -const DUMMY_SALT: &[u8] = b"some dummy salt"; - -pub struct Task { - data: &'static [u8], - cost: u32, -} - -impl Task { - pub fn new(data: &'static [u8], cost: u32) -> Self { - Self { data, cost } - } - - pub fn execute(&self) { - let mut key1 = [0u8; 20]; - pbkdf2_hmac::(self.data, DUMMY_SALT, self.cost, &mut key1); - } -} +pub use task::Task; diff --git a/src/task.rs b/src/task.rs new file mode 100644 index 0000000..8fac2b2 --- /dev/null +++ b/src/task.rs @@ -0,0 +1,21 @@ +use pbkdf2::pbkdf2_hmac; +use sha2::Sha256; + +const DUMMY_SALT: &[u8] = b"some dummy salt"; + +#[derive(Clone, Debug)] +pub struct Task { + pub data: &'static [u8], + pub cost: u32, +} + +impl Task { + pub fn new(data: &'static [u8], cost: u32) -> Self { + Self { data, cost } + } + + pub fn execute(&self) { + let mut key1 = [0u8; 20]; + pbkdf2_hmac::(self.data, DUMMY_SALT, self.cost, &mut key1); + } +}