aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2018-06-10 21:32:21 +0200
committerKatharina Fey <kookie@spacekookie.de>2018-06-10 21:32:21 +0200
commit152be3068866a39ef355276da2f906df1cbc5568 (patch)
tree2684e20bc558375157b687379d47389a6dc8c669
parentdc5c782b7e787dcf513ec54d6186d398d06e07cb (diff)
Actually adding new meta files
-rw-r--r--Cargo.lock12
-rw-r--r--lockchain-core/src/meta.rs61
2 files changed, 67 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 75226d1..b67d7a1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -801,12 +801,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "lockchain-client"
version = "0.0.0"
dependencies = [
- "lockchain-core 0.7.2",
+ "lockchain-core 0.8.0",
]
[[package]]
name = "lockchain-core"
-version = "0.7.2"
+version = "0.8.0"
dependencies = [
"base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bcrypt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -822,7 +822,7 @@ dependencies = [
name = "lockchain-crypto"
version = "0.7.0"
dependencies = [
- "lockchain-core 0.7.2",
+ "lockchain-core 0.8.0",
"miscreant 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -832,7 +832,7 @@ dependencies = [
name = "lockchain-files"
version = "0.7.1"
dependencies = [
- "lockchain-core 0.7.2",
+ "lockchain-core 0.8.0",
]
[[package]]
@@ -843,7 +843,7 @@ dependencies = [
"actix-web 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
- "lockchain-core 0.7.2",
+ "lockchain-core 0.8.0",
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -854,7 +854,7 @@ version = "0.1.0"
dependencies = [
"clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
"insult 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "lockchain-core 0.7.2",
+ "lockchain-core 0.8.0",
"lockchain-files 0.7.1",
"lockchain-http 0.2.1",
]
diff --git a/lockchain-core/src/meta.rs b/lockchain-core/src/meta.rs
new file mode 100644
index 0000000..a602e48
--- /dev/null
+++ b/lockchain-core/src/meta.rs
@@ -0,0 +1,61 @@
+//! A cleartext metadata record for a vault metadata store
+//!
+//! This MetaItem uses a lot of the same traits and mechanisms
+//! as the normal Vault Record, without having to rely on encryption
+//! or trait base security.
+
+use record::Payload;
+use std::collections::HashMap;
+use traits::{AutoEncoder, Body};
+
+/// A metadomain is a simplified version of a cleartext record.
+///
+/// It is not encoded in special ways, it is not used in any way
+/// for secret information. All data inside a metadata file
+/// (for example, living inside the `metadata` folder of a vault)
+/// is public to all.
+///
+/// It can be used for things that need to be stored in encrypted form
+/// where the encryption key is never present. Or for simple authentication
+/// verification such as:
+///
+/// - User registry
+/// - Per-user encrypted primary keys
+/// - Usage statistics shared between clients
+///
+/// It implements a series of traits which means it's possible to easily
+/// interact with to store data.
+#[derive(Serialize, Deserialize)]
+pub struct MetaDomain {
+ /// The name of this meta domain
+ name: String,
+ body: HashMap<String, Payload>,
+}
+
+impl MetaDomain {
+ /// Return the domain name for easy comparison
+ pub fn name(&self) -> &str {
+ &self.name
+ }
+ /// Get the number of items in this domain
+ pub fn size(&self) -> usize {
+ self.body.len()
+ }
+}
+
+impl AutoEncoder for MetaDomain {}
+
+impl Body for MetaDomain {
+ fn get_field(&self, name: &str) -> Option<&Payload> {
+ self.body.get(name)
+ }
+
+ fn set_field(&mut self, key: &str, value: Payload) -> Option<()> {
+ self.body.insert(key.into(), value).map(|_| ())
+ }
+
+ /// Not implemented, always returns None
+ fn flatten(&mut self) -> Option<()> {
+ None
+ }
+}