aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Sabel <katharina.sabel@asquera.de>2018-04-16 10:21:28 +0200
committerKatharina Sabel <katharina.sabel@asquera.de>2018-04-16 10:21:28 +0200
commitff07b004c16939c86ac89a4d25b3ca1e243b172e (patch)
treeca458c3d3cdea804719773e38297a66037e0aade
parent7d62ae013640e00984d1d1ffed64857d949aa7c3 (diff)
Adding some new functions and bumping the version to 0.2.0
-rw-r--r--Cargo.lock4
-rw-r--r--lockchain-core/Cargo.toml2
-rw-r--r--lockchain-core/src/core.rs0
-rw-r--r--lockchain-core/src/record.rs21
4 files changed, 23 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 517c9f4..167bbd5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -202,12 +202,12 @@ name = "lockchain-cli"
version = "0.1.0"
dependencies = [
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "lockchain-core 0.1.1",
+ "lockchain-core 0.2.0",
]
[[package]]
name = "lockchain-core"
-version = "0.1.1"
+version = "0.2.0"
dependencies = [
"base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"blake2 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/lockchain-core/Cargo.toml b/lockchain-core/Cargo.toml
index 5783335..0f1286b 100644
--- a/lockchain-core/Cargo.toml
+++ b/lockchain-core/Cargo.toml
@@ -5,7 +5,7 @@ docs = "https://docs.rs/lockchain-core"
website = "https://github.com/spacekookie/lockchain/tree/master/lockchain-core"
readme = "README.md"
license = "MIT/X11 OR Apache-2.0"
-version = "0.1.1"
+version = "0.2.0"
authors = ["Katharina Fey <kookie@spacekookie.de>"]
[dependencies]
diff --git a/lockchain-core/src/core.rs b/lockchain-core/src/core.rs
deleted file mode 100644
index e69de29..0000000
--- a/lockchain-core/src/core.rs
+++ /dev/null
diff --git a/lockchain-core/src/record.rs b/lockchain-core/src/record.rs
index 03d3262..5f721c0 100644
--- a/lockchain-core/src/record.rs
+++ b/lockchain-core/src/record.rs
@@ -5,6 +5,7 @@
use std::collections::BTreeMap;
use chrono::{Local, DateTime};
+use serde_json;
/// A generic payload for a record
@@ -16,6 +17,12 @@ pub enum Payload {
BTreeMap(BTreeMap<String, Payload>),
}
+/// The header of a record
+///
+/// Contains easily searchable fields of metadata. Nothing
+/// in the Header should ever be considered secure as the
+/// headers are kept cached for much longer than the rest
+/// of the data.
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct Header {
pub name: String,
@@ -26,10 +33,10 @@ pub struct Header {
pub date_updated: DateTime<Local>,
}
+///
#[derive(Debug, Serialize, Deserialize)]
pub struct Record {
pub header: Header,
- // pub fields: BTreeMap<String, Payload>,
pub body: BTreeMap<String, Payload>,
}
@@ -73,6 +80,18 @@ impl Record {
self.body.insert(String::from(key), val);
}
+ /// Contains a cloned value of single data field
+ pub fn get_data(&self, key: &str) -> Payload {
+ return self.body.get(key).unwrap().clone();
+ }
+
+ /// Serialise the entire body into a json tree
+ ///
+ /// Contains all secret values in a json tree that you can work with manually.
+ pub fn get_json(&self) -> String {
+ return serde_json::to_string(&self.body).unwrap();
+ }
+
/// Add a new tag to this record head. Checks that tags don't already exists
pub fn add_tag(&mut self, tag: &str) {
self.header.tags.push(String::from(tag));