From 438b1d759cfe438740c648850ec82e7259bd452f Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 7 Mar 2022 12:25:40 +0000 Subject: [PATCH] Simplify datastore keys --- lib/src/key/database.rs | 17 ++++++++--------- lib/src/key/db.rs | 21 ++++++++++++--------- lib/src/key/dl.rs | 35 +++++++++++++++++++---------------- lib/src/key/dt.rs | 27 +++++++++++++++------------ lib/src/key/ev.rs | 33 ++++++++++++++++++--------------- lib/src/key/fd.rs | 33 ++++++++++++++++++--------------- lib/src/key/ft.rs | 33 ++++++++++++++++++--------------- lib/src/key/index.rs | 31 +++++++++++++++---------------- lib/src/key/ix.rs | 33 ++++++++++++++++++--------------- lib/src/key/key.rs | 2 -- lib/src/key/lv.rs | 33 ++++++++++++++++++--------------- lib/src/key/namespace.rs | 11 +++++------ lib/src/key/nl.rs | 21 ++++++++++++--------- lib/src/key/ns.rs | 15 +++++++++------ lib/src/key/nt.rs | 21 ++++++++++++--------- lib/src/key/point.rs | 33 ++++++++++++++++----------------- lib/src/key/sc.rs | 27 +++++++++++++++------------ lib/src/key/st.rs | 37 ++++++++++++++++++++++--------------- lib/src/key/table.rs | 23 +++++++++++------------ lib/src/key/tb.rs | 27 +++++++++++++++------------ lib/src/key/thing.rs | 35 ++++++++++++++++++++--------------- 21 files changed, 296 insertions(+), 252 deletions(-) diff --git a/lib/src/key/database.rs b/lib/src/key/database.rs index 2ab7a489..f2a25a07 100644 --- a/lib/src/key/database.rs +++ b/lib/src/key/database.rs @@ -1,15 +1,14 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Database { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, } impl From for Vec { @@ -31,10 +30,10 @@ pub fn new(ns: &str, db: &str) -> Database { impl Database { pub fn new(ns: String, db: String) -> Database { Database { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, } } diff --git a/lib/src/key/db.rs b/lib/src/key/db.rs index 2f327d54..fd19ea5b 100644 --- a/lib/src/key/db.rs +++ b/lib/src/key/db.rs @@ -1,15 +1,16 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Db { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, + __: char, + _a: char, + pub ns: String, + _b: char, + _c: char, + _d: char, + pub db: String, } impl From for Vec { @@ -31,10 +32,12 @@ pub fn new(ns: &str, db: &str) -> Db { impl Db { pub fn new(ns: String, db: String) -> Db { Db { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("!db"), + _b: '!', + _c: 'd', + _d: 'b', db, } } diff --git a/lib/src/key/dl.rs b/lib/src/key/dl.rs index da332345..8e2da4c9 100644 --- a/lib/src/key/dl.rs +++ b/lib/src/key/dl.rs @@ -1,17 +1,18 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Dl { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - us: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + _d: char, + _e: char, + pub dl: String, } impl From
for Vec { @@ -26,20 +27,22 @@ impl From> for Dl { } } -pub fn new(ns: &str, db: &str, us: &str) -> Dl { - Dl::new(ns.to_string(), db.to_string(), us.to_string()) +pub fn new(ns: &str, db: &str, dl: &str) -> Dl { + Dl::new(ns.to_string(), db.to_string(), dl.to_string()) } impl Dl { - pub fn new(ns: String, db: String, us: String) -> Dl { + pub fn new(ns: String, db: String, dl: String) -> Dl { Dl { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("!us"), - us, + _c: '!', + _d: 'd', + _e: 'l', + dl, } } pub fn encode(&self) -> Result, Error> { diff --git a/lib/src/key/dt.rs b/lib/src/key/dt.rs index b09edca5..0cb03f95 100644 --- a/lib/src/key/dt.rs +++ b/lib/src/key/dt.rs @@ -1,17 +1,18 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Dt { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tk: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + _d: char, + _e: char, + pub tk: String, } impl From
for Vec { @@ -33,12 +34,14 @@ pub fn new(ns: &str, db: &str, tb: &str) -> Dt { impl Dt { pub fn new(ns: String, db: String, tk: String) -> Dt { Dt { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("!tk"), + _c: '!', + _d: 'd', + _e: 't', tk, } } diff --git a/lib/src/key/ev.rs b/lib/src/key/ev.rs index 0b3e4c96..18c32bc7 100644 --- a/lib/src/key/ev.rs +++ b/lib/src/key/ev.rs @@ -1,19 +1,20 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Ev { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - ev: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + _e: char, + _f: char, + pub ev: String, } impl From for Vec { @@ -35,14 +36,16 @@ pub fn new(ns: &str, db: &str, tb: &str, ev: &str) -> Ev { impl Ev { pub fn new(ns: String, db: String, tb: String, ev: String) -> Ev { Ev { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("!ev"), + _d: '!', + _e: 'e', + _f: 'v', ev, } } diff --git a/lib/src/key/fd.rs b/lib/src/key/fd.rs index d7fb4f08..929864ba 100644 --- a/lib/src/key/fd.rs +++ b/lib/src/key/fd.rs @@ -1,19 +1,20 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Fd { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - fd: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + _e: char, + _f: char, + pub fd: String, } impl From for Vec { @@ -35,14 +36,16 @@ pub fn new(ns: &str, db: &str, tb: &str, fd: &str) -> Fd { impl Fd { pub fn new(ns: String, db: String, tb: String, fd: String) -> Fd { Fd { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("!fd"), + _d: '!', + _e: 'f', + _f: 'd', fd, } } diff --git a/lib/src/key/ft.rs b/lib/src/key/ft.rs index 82c54676..b5d01035 100644 --- a/lib/src/key/ft.rs +++ b/lib/src/key/ft.rs @@ -1,19 +1,20 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Ft { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _d: String, - tb: String, - _c: String, - ft: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + _e: char, + _f: char, + pub ft: String, } impl From for Vec { @@ -35,14 +36,16 @@ pub fn new(ns: &str, db: &str, tb: &str, ft: &str) -> Ft { impl Ft { pub fn new(ns: String, db: String, tb: String, ft: String) -> Ft { Ft { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("!ft"), + _d: '!', + _e: 'f', + _f: 't', ft, } } diff --git a/lib/src/key/index.rs b/lib/src/key/index.rs index 96355461..88a6c5f2 100644 --- a/lib/src/key/index.rs +++ b/lib/src/key/index.rs @@ -1,21 +1,20 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use crate::sql::value::Value; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Index { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - ix: String, - fd: Value, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + pub ix: String, + pub fd: Value, } impl From for Vec { @@ -37,14 +36,14 @@ pub fn new(ns: &str, db: &str, tb: &str, ix: &str, fd: Value) -> Index { impl Index { pub fn new(ns: String, db: String, tb: String, ix: String, fd: Value) -> Index { Index { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("¤"), + _d: '¤', ix, fd, } diff --git a/lib/src/key/ix.rs b/lib/src/key/ix.rs index e54411ba..bbe23df3 100644 --- a/lib/src/key/ix.rs +++ b/lib/src/key/ix.rs @@ -1,19 +1,20 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Ix { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - ix: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + _e: char, + _f: char, + pub ix: String, } impl From for Vec { @@ -35,14 +36,16 @@ pub fn new(ns: &str, db: &str, tb: &str, ix: &str) -> Ix { impl Ix { pub fn new(ns: String, db: String, tb: String, ix: String) -> Ix { Ix { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("!ix"), + _d: '!', + _e: 'i', + _f: 'x', ix, } } diff --git a/lib/src/key/key.rs b/lib/src/key/key.rs index cfea6bb2..03cb163e 100644 --- a/lib/src/key/key.rs +++ b/lib/src/key/key.rs @@ -3,8 +3,6 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; use serde::{Deserialize, Serialize}; -// Default base key -pub const BASE: &str = "surreal"; // Ignore specifies an ignored field pub const IGNORE: &str = "\x00"; // Prefix is the lowest char found in a key diff --git a/lib/src/key/lv.rs b/lib/src/key/lv.rs index 82b856c7..a3951bc8 100644 --- a/lib/src/key/lv.rs +++ b/lib/src/key/lv.rs @@ -1,19 +1,20 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Lv { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - lv: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + _e: char, + _f: char, + pub lv: String, } impl From for Vec { @@ -35,14 +36,16 @@ pub fn new(ns: &str, db: &str, tb: &str, lv: &str) -> Lv { impl Lv { pub fn new(ns: String, db: String, tb: String, lv: String) -> Lv { Lv { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("!lv"), + _d: '!', + _e: 'l', + _f: 'v', lv, } } diff --git a/lib/src/key/namespace.rs b/lib/src/key/namespace.rs index ccb2af96..d77acc52 100644 --- a/lib/src/key/namespace.rs +++ b/lib/src/key/namespace.rs @@ -1,13 +1,12 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Namespace { - kv: String, - _a: String, - ns: String, + __: char, + _a: char, + pub ns: String, } impl From for Vec { @@ -29,8 +28,8 @@ pub fn new(ns: &str) -> Namespace { impl Namespace { pub fn new(ns: String) -> Namespace { Namespace { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, } } diff --git a/lib/src/key/nl.rs b/lib/src/key/nl.rs index 6333304c..bba52631 100644 --- a/lib/src/key/nl.rs +++ b/lib/src/key/nl.rs @@ -1,15 +1,16 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Nl { - kv: String, - _a: String, - ns: String, - _b: String, - us: String, + __: char, + _a: char, + pub ns: String, + _b: char, + _c: char, + _d: char, + pub us: String, } impl From for Vec { @@ -31,10 +32,12 @@ pub fn new(ns: &str, us: &str) -> Nl { impl Nl { pub fn new(ns: String, us: String) -> Nl { Nl { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("!us"), + _b: '!', + _c: 'n', + _d: 'l', us, } } diff --git a/lib/src/key/ns.rs b/lib/src/key/ns.rs index ba07001d..bada44ed 100644 --- a/lib/src/key/ns.rs +++ b/lib/src/key/ns.rs @@ -1,13 +1,14 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Ns { - kv: String, - _a: String, - ns: String, + __: char, + _a: char, + _b: char, + _c: char, + pub ns: String, } impl From for Vec { @@ -29,8 +30,10 @@ pub fn new(ns: &str) -> Ns { impl Ns { pub fn new(ns: String) -> Ns { Ns { - kv: BASE.to_owned(), - _a: String::from("!ns"), + __: '/', + _a: '!', + _b: 'n', + _c: 's', ns, } } diff --git a/lib/src/key/nt.rs b/lib/src/key/nt.rs index 58d381b9..f92642a7 100644 --- a/lib/src/key/nt.rs +++ b/lib/src/key/nt.rs @@ -1,15 +1,16 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Nt { - kv: String, - _a: String, - ns: String, - _b: String, - tk: String, + __: char, + _a: char, + pub ns: String, + _b: char, + _c: char, + _d: char, + pub tk: String, } impl From for Vec { @@ -31,10 +32,12 @@ pub fn new(ns: &str, tk: &str) -> Nt { impl Nt { pub fn new(ns: String, tk: String) -> Nt { Nt { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("!tk"), + _b: '!', + _c: 'n', + _d: 't', tk, } } diff --git a/lib/src/key/point.rs b/lib/src/key/point.rs index 34245671..e5cde9a4 100644 --- a/lib/src/key/point.rs +++ b/lib/src/key/point.rs @@ -1,22 +1,21 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use crate::sql::value::Value; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Point { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - ix: String, - fd: Value, - id: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + pub ix: String, + pub fd: Value, + pub id: String, } impl From for Vec { @@ -38,14 +37,14 @@ pub fn new(ns: &str, db: &str, tb: &str, ix: &str, fd: Value, id: &str) -> Point impl Point { pub fn new(ns: String, db: String, tb: String, ix: String, fd: Value, id: String) -> Point { Point { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("¤"), + _d: '¤', ix, fd, id, diff --git a/lib/src/key/sc.rs b/lib/src/key/sc.rs index 560cf0d3..7b3aabbe 100644 --- a/lib/src/key/sc.rs +++ b/lib/src/key/sc.rs @@ -1,17 +1,18 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Sc { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - sc: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + _d: char, + _e: char, + pub sc: String, } impl From for Vec { @@ -33,12 +34,14 @@ pub fn new(ns: &str, db: &str, sc: &str) -> Sc { impl Sc { pub fn new(ns: String, db: String, sc: String) -> Sc { Sc { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("!sc"), + _c: '!', + _d: 's', + _e: 'c', sc, } } diff --git a/lib/src/key/st.rs b/lib/src/key/st.rs index e10355e9..c7890779 100644 --- a/lib/src/key/st.rs +++ b/lib/src/key/st.rs @@ -1,19 +1,22 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct St { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - sc: String, - _d: String, - tk: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + _d: char, + _e: char, + pub sc: String, + _f: char, + _g: char, + _h: char, + pub tk: String, } impl From for Vec { @@ -35,14 +38,18 @@ pub fn new(ns: &str, db: &str, sc: &str, tk: &str) -> St { impl St { pub fn new(ns: String, db: String, sc: String, tk: String) -> St { St { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("!st"), + _c: '!', + _d: 's', + _e: 't', sc, - _d: String::from("!tk"), + _f: '!', + _g: 't', + _h: 'k', tk, } } diff --git a/lib/src/key/table.rs b/lib/src/key/table.rs index aba2b8ef..bf4231ce 100644 --- a/lib/src/key/table.rs +++ b/lib/src/key/table.rs @@ -1,17 +1,16 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Table { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, } impl From for Vec { @@ -33,12 +32,12 @@ pub fn new(ns: &str, db: &str, tb: &str) -> Table { impl Table { pub fn new(ns: String, db: String, tb: String) -> Table { Table { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, } } diff --git a/lib/src/key/tb.rs b/lib/src/key/tb.rs index caceb6f7..9cac5a0c 100644 --- a/lib/src/key/tb.rs +++ b/lib/src/key/tb.rs @@ -1,17 +1,18 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Tb { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + _d: char, + _e: char, + pub tb: String, } impl From for Vec { @@ -33,12 +34,14 @@ pub fn new(ns: &str, db: &str, tb: &str) -> Tb { impl Tb { pub fn new(ns: String, db: String, tb: String) -> Tb { Tb { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("!tb"), + _c: '!', + _d: 't', + _e: 'b', tb, } } diff --git a/lib/src/key/thing.rs b/lib/src/key/thing.rs index 80bb809a..1c443d55 100644 --- a/lib/src/key/thing.rs +++ b/lib/src/key/thing.rs @@ -1,19 +1,18 @@ use crate::err::Error; use crate::key::bytes::{deserialize, serialize}; -use crate::key::BASE; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Thing { - kv: String, - _a: String, - ns: String, - _b: String, - db: String, - _c: String, - tb: String, - _d: String, - id: String, + __: char, + _a: char, + pub ns: String, + _b: char, + pub db: String, + _c: char, + pub tb: String, + _d: char, + pub id: String, } impl From for Vec { @@ -28,6 +27,12 @@ impl From> for Thing { } } +impl From<&Vec> for Thing { + fn from(val: &Vec) -> Self { + Thing::decode(&val).unwrap() + } +} + pub fn new(ns: &str, db: &str, tb: &str, id: &str) -> Thing { Thing::new(ns.to_string(), db.to_string(), tb.to_string(), id.to_string()) } @@ -35,14 +40,14 @@ pub fn new(ns: &str, db: &str, tb: &str, id: &str) -> Thing { impl Thing { pub fn new(ns: String, db: String, tb: String, id: String) -> Thing { Thing { - kv: BASE.to_owned(), - _a: String::from("*"), + __: '/', + _a: '*', ns, - _b: String::from("*"), + _b: '*', db, - _c: String::from("*"), + _c: '*', tb, - _d: String::from("*"), + _d: '*', id, } }