diff options
author | Katharina Sabel <katharina.sabel@asquera.de> | 2018-05-08 00:32:21 +0200 |
---|---|---|
committer | Katharina Sabel <katharina.sabel@asquera.de> | 2018-05-08 00:32:21 +0200 |
commit | 2aa9772596b12496c05c46caed9c7c8c5ae9b32a (patch) | |
tree | 19cd3d80a2c30ed1a4e4ad97252b69e757180dd9 /lockchain-crypto/src | |
parent | 3c4030f8fd00c6445731bb102169b4b6b5d6d70e (diff) |
Restructuring traits that handle encryption module
Diffstat (limited to 'lockchain-crypto/src')
-rw-r--r-- | lockchain-crypto/src/databody.rs | 27 | ||||
-rw-r--r-- | lockchain-crypto/src/engine.rs | 19 | ||||
-rw-r--r-- | lockchain-crypto/src/lib.rs | 37 |
3 files changed, 52 insertions, 31 deletions
diff --git a/lockchain-crypto/src/databody.rs b/lockchain-crypto/src/databody.rs new file mode 100644 index 0000000..1387f9d --- /dev/null +++ b/lockchain-crypto/src/databody.rs @@ -0,0 +1,27 @@ +//! + +use lcc::traits::{AutoEncoder, Body}; +use lcc::Payload; +use std::collections::BTreeMap; + +#[derive(Serialize, Deserialize)] +pub struct DataBody { + tree: BTreeMap<String, Payload>, +} + +impl AutoEncoder for DataBody {} + +impl Body for DataBody { + fn get_field(&self, key: &str) -> Option<&Payload> { + self.tree.get(key) + } + + fn set_field(&mut self, key: &str, value: Payload) -> Option<()> { + self.tree.insert(key.to_owned(), value)?; + Some(()) + } + + fn flatten(&mut self) -> Option<()> { + None + } +} diff --git a/lockchain-crypto/src/engine.rs b/lockchain-crypto/src/engine.rs new file mode 100644 index 0000000..1030bf2 --- /dev/null +++ b/lockchain-crypto/src/engine.rs @@ -0,0 +1,19 @@ +//! + +use databody::DataBody; +use lcc::{traits::{Encryptable, EncryptionHandler}, + EncryptedBody}; + +impl Encryptable for DataBody {} + +pub struct AesEngine {} + +impl EncryptionHandler<DataBody> for AesEngine { + fn encrypt(&mut self, item: DataBody) -> EncryptedBody { + unimplemented!() + } + + fn decrypt(&mut self, item: EncryptedBody) -> DataBody { + unimplemented!() + } +} diff --git a/lockchain-crypto/src/lib.rs b/lockchain-crypto/src/lib.rs index 5648106..0799c96 100644 --- a/lockchain-crypto/src/lib.rs +++ b/lockchain-crypto/src/lib.rs @@ -6,37 +6,12 @@ extern crate serde; extern crate lockchain_core as lcc; -use lcc::{Payload, EncryptedBody}; -use lcc::traits::{Body, AutoEncoder, Base64AutoEncoder, Encryption}; - +use lcc::{traits::{AutoEncoder, Body}, + Payload}; use std::collections::BTreeMap; -#[derive(Serialize, Deserialize)] -pub struct DataBody { - tree: BTreeMap<String, Payload>, -} - -impl AutoEncoder for DataBody {} - -impl Body for DataBody { - fn get_field(&self, key: &str) -> Option<&Payload> { - self.tree.get(key).as_ref()? - } - - fn set_field(&mut self, key: &str, value: Payload) -> Option<()> { - self.tree.insert(key, value); - Some(()) - } - - fn flatten(&mut self) -> Option<()> { - None - } -} +mod databody; +mod engine; -impl Encryption for DataBody { - fn encrypt(&mut self) -> EncryptedBody { - EncryptedBody { - cipher: self.encode() - } - } -}
\ No newline at end of file +pub use databody::*; +pub use engine::*; |