From df745bb3a52ad4e9a6cc96829f05cd40d57ae9bd Mon Sep 17 00:00:00 2001 From: Przemyslaw Hugh Kaznowski Date: Sat, 13 May 2023 00:40:45 +0100 Subject: [PATCH] Favour rust binary characters instead of hex (#1978) --- lib/src/key/az.rs | 16 ++++++++-------- lib/src/key/database.rs | 6 +++--- lib/src/key/db.rs | 14 +++++++------- lib/src/key/dl.rs | 16 ++++++++-------- lib/src/key/dt.rs | 16 ++++++++-------- lib/src/key/ev.rs | 18 +++++++++--------- lib/src/key/fc.rs | 16 ++++++++-------- lib/src/key/fd.rs | 18 +++++++++--------- lib/src/key/ft.rs | 18 +++++++++--------- lib/src/key/graph.rs | 40 ++++++++++++++++++++-------------------- lib/src/key/index.rs | 21 +++++++++++---------- lib/src/key/ix.rs | 18 +++++++++--------- lib/src/key/kv.rs | 2 +- lib/src/key/lq.rs | 12 ++++++------ lib/src/key/lv.rs | 18 +++++++++--------- lib/src/key/mod.rs | 3 +++ lib/src/key/namespace.rs | 4 ++-- lib/src/key/nl.rs | 14 +++++++------- lib/src/key/ns.rs | 12 ++++++------ lib/src/key/nt.rs | 14 +++++++------- lib/src/key/pa.rs | 16 ++++++++-------- lib/src/key/sc.rs | 16 ++++++++-------- lib/src/key/scope.rs | 9 +++++---- lib/src/key/st.rs | 19 ++++++++++--------- lib/src/key/table.rs | 8 ++++---- lib/src/key/tb.rs | 16 ++++++++-------- lib/src/key/thing.rs | 14 +++++++------- 27 files changed, 200 insertions(+), 194 deletions(-) diff --git a/lib/src/key/az.rs b/lib/src/key/az.rs index dbd15a98..228da1a8 100644 --- a/lib/src/key/az.rs +++ b/lib/src/key/az.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Az<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x61, 0x7a, 0x00]); + k.extend_from_slice(&[b'!', b'a', b'z', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x61, 0x7a, 0xff]); + k.extend_from_slice(&[b'!', b'a', b'z', 0xff]); k } impl<'a> Az<'a> { pub fn new(ns: &'a str, db: &'a str, az: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', // / + _a: b'*', // * ns, - _b: 0x2a, // * + _b: b'*', // * db, - _c: 0x21, // ! - _d: 0x61, // a - _e: 0x7a, // z + _c: b'!', // ! + _d: b'a', // a + _e: b'z', // z az, } } diff --git a/lib/src/key/database.rs b/lib/src/key/database.rs index d9bf5383..bad01bd9 100644 --- a/lib/src/key/database.rs +++ b/lib/src/key/database.rs @@ -17,10 +17,10 @@ pub fn new<'a>(ns: &'a str, db: &'a str) -> Database<'a> { impl<'a> Database<'a> { pub fn new(ns: &'a str, db: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', // / + _a: b'*', // * ns, - _b: 0x2a, // * + _b: b'*', // * db, } } diff --git a/lib/src/key/db.rs b/lib/src/key/db.rs index be447eff..b2a55780 100644 --- a/lib/src/key/db.rs +++ b/lib/src/key/db.rs @@ -18,25 +18,25 @@ pub fn new<'a>(ns: &'a str, db: &'a str) -> Db<'a> { pub fn prefix(ns: &str) -> Vec { let mut k = super::namespace::new(ns).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x64, 0x62, 0x00]); + k.extend_from_slice(&[b'!', b'd', b'b', 0x00]); k } pub fn suffix(ns: &str) -> Vec { let mut k = super::namespace::new(ns).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x64, 0x62, 0xff]); + k.extend_from_slice(&[b'!', b'd', b'b', 0xff]); k } impl<'a> Db<'a> { pub fn new(ns: &'a str, db: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x21, // ! - _c: 0x64, // d - _d: 0x62, // b + _b: b'!', + _c: b'd', + _d: b'b', db, } } diff --git a/lib/src/key/dl.rs b/lib/src/key/dl.rs index c6b851d7..88b5a479 100644 --- a/lib/src/key/dl.rs +++ b/lib/src/key/dl.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, dl: &'a str) -> Dl<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x64, 0x6c, 0x00]); + k.extend_from_slice(&[b'!', b'd', b'l', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x64, 0x6c, 0xff]); + k.extend_from_slice(&[b'!', b'd', b'l', 0xff]); k } impl<'a> Dl<'a> { pub fn new(ns: &'a str, db: &'a str, dl: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x64, // d - _e: 0x6c, // l + _c: b'!', + _d: b'd', + _e: b'l', dl, } } diff --git a/lib/src/key/dt.rs b/lib/src/key/dt.rs index 5d68c486..20dc5b6c 100644 --- a/lib/src/key/dt.rs +++ b/lib/src/key/dt.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Dt<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x64, 0x74, 0x00]); + k.extend_from_slice(&[b'!', b'd', b't', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x64, 0x74, 0xff]); + k.extend_from_slice(&[b'!', b'd', b't', 0xff]); k } impl<'a> Dt<'a> { pub fn new(ns: &'a str, db: &'a str, tk: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x64, // d - _e: 0x74, // t + _c: b'!', + _d: b'd', + _e: b't', tk, } } diff --git a/lib/src/key/ev.rs b/lib/src/key/ev.rs index 92904039..2517295a 100644 --- a/lib/src/key/ev.rs +++ b/lib/src/key/ev.rs @@ -22,29 +22,29 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ev: &'a str) -> Ev<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x65, 0x76, 0x00]); + k.extend_from_slice(&[b'!', b'e', b'v', 0x00]); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x65, 0x76, 0xff]); + k.extend_from_slice(&[b'!', b'e', b'v', 0xff]); k } impl<'a> Ev<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, ev: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x21, // ! - _e: 0x65, // e - _f: 0x76, // v + _d: b'!', + _e: b'e', + _f: b'v', ev, } } diff --git a/lib/src/key/fc.rs b/lib/src/key/fc.rs index cc2e5652..4cac00bc 100644 --- a/lib/src/key/fc.rs +++ b/lib/src/key/fc.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, fc: &'a str) -> Fc<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x66, 0x6e, 0x00]); + k.extend_from_slice(&[b'!', b'f', b'n', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x66, 0x6e, 0xff]); + k.extend_from_slice(&[b'!', b'f', b'n', 0xff]); k } impl<'a> Fc<'a> { pub fn new(ns: &'a str, db: &'a str, fc: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x66, // f - _e: 0x6e, // n + _c: b'!', + _d: b'f', + _e: b'n', fc, } } diff --git a/lib/src/key/fd.rs b/lib/src/key/fd.rs index ee33bda2..e5d690ed 100644 --- a/lib/src/key/fd.rs +++ b/lib/src/key/fd.rs @@ -22,29 +22,29 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, fd: &'a str) -> Fd<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x66, 0x64, 0x00]); + k.extend_from_slice(&[b'!', b'f', b'd', 0x00]); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x66, 0x64, 0xff]); + k.extend_from_slice(&[b'!', b'f', b'd', 0xff]); k } impl<'a> Fd<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, fd: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x21, // ! - _e: 0x66, // f - _f: 0x64, // d + _d: b'!', + _e: b'f', + _f: b'd', fd, } } diff --git a/lib/src/key/ft.rs b/lib/src/key/ft.rs index 6042c3ad..80d85f38 100644 --- a/lib/src/key/ft.rs +++ b/lib/src/key/ft.rs @@ -22,29 +22,29 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ft: &'a str) -> Ft<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x66, 0x74, 0x00]); + k.extend_from_slice(&[b'!', b'f', b't', 0x00]); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x66, 0x74, 0xff]); + k.extend_from_slice(&[b'!', b'f', b't', 0xff]); k } impl<'a> Ft<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, ft: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x21, // ! - _e: 0x66, // f - _f: 0x74, // t + _d: b'!', + _e: b'f', + _f: b't', ft, } } diff --git a/lib/src/key/graph.rs b/lib/src/key/graph.rs index 762c5989..883164b6 100644 --- a/lib/src/key/graph.rs +++ b/lib/src/key/graph.rs @@ -20,14 +20,14 @@ struct Prefix<'a> { impl<'a> Prefix<'a> { fn new(ns: &'a str, db: &'a str, tb: &'a str, id: &Id) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x7e, // ~ + _d: b'~', id: id.to_owned(), } } @@ -50,14 +50,14 @@ struct PrefixEg<'a> { impl<'a> PrefixEg<'a> { fn new(ns: &'a str, db: &'a str, tb: &'a str, id: &Id, eg: &Dir) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x7e, // ~ + _d: b'~', id: id.to_owned(), eg: eg.to_owned(), } @@ -82,14 +82,14 @@ struct PrefixFt<'a> { impl<'a> PrefixFt<'a> { fn new(ns: &'a str, db: &'a str, tb: &'a str, id: &Id, eg: &Dir, ft: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x7e, // ~ + _d: b'~', id: id.to_owned(), eg: eg.to_owned(), ft, @@ -163,14 +163,14 @@ pub fn ftsuffix(ns: &str, db: &str, tb: &str, id: &Id, eg: &Dir, ft: &str) -> Ve impl<'a> Graph<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, id: Id, eg: Dir, fk: &'a Thing) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x7e, // ~ + _d: b'~', id, eg, ft: &fk.tb, diff --git a/lib/src/key/index.rs b/lib/src/key/index.rs index a560484a..5565f160 100644 --- a/lib/src/key/index.rs +++ b/lib/src/key/index.rs @@ -1,3 +1,4 @@ +use crate::key::CHAR_INDEX; use crate::sql::array::Array; use crate::sql::id::Id; use derive::Key; @@ -19,14 +20,14 @@ struct Prefix<'a> { impl<'a> Prefix<'a> { fn new(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0xa4, // ¤ + _d: CHAR_INDEX, ix, } } @@ -80,14 +81,14 @@ impl<'a> Index<'a> { id: Option, ) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0xa4, // ¤ + _d: CHAR_INDEX, ix, fd, id, diff --git a/lib/src/key/ix.rs b/lib/src/key/ix.rs index 0d28ab23..e5fa314c 100644 --- a/lib/src/key/ix.rs +++ b/lib/src/key/ix.rs @@ -22,29 +22,29 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Ix<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x69, 0x78, 0x00]); + k.extend_from_slice(&[b'!', b'i', b'x', 0x00]); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x69, 0x78, 0xff]); + k.extend_from_slice(&[b'!', b'i', b'x', 0xff]); k } impl<'a> Ix<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x21, // ! - _e: 0x69, // i - _f: 0x78, // x + _d: b'!', + _e: b'i', + _f: b'x', ix, } } diff --git a/lib/src/key/kv.rs b/lib/src/key/kv.rs index 7965f296..3aeb7843 100644 --- a/lib/src/key/kv.rs +++ b/lib/src/key/kv.rs @@ -19,7 +19,7 @@ impl Default for Kv { impl Kv { pub fn new() -> Kv { Kv { - __: 0x2f, // / + __: b'/', } } } diff --git a/lib/src/key/lq.rs b/lib/src/key/lq.rs index daa64bb0..0f229cd9 100644 --- a/lib/src/key/lq.rs +++ b/lib/src/key/lq.rs @@ -22,14 +22,14 @@ pub fn new<'a>(ns: &'a str, db: &'a str, lq: &Uuid) -> Lq<'a> { impl<'a> Lq<'a> { pub fn new(ns: &'a str, db: &'a str, lq: Uuid) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x6c, // l - _e: 0x71, // v + _c: b'!', + _d: b'l', + _e: b'v', lq, } } diff --git a/lib/src/key/lv.rs b/lib/src/key/lv.rs index 51b13d06..22e68554 100644 --- a/lib/src/key/lv.rs +++ b/lib/src/key/lv.rs @@ -23,29 +23,29 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, lv: &Uuid) -> Lv<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6c, 0x76, 0x00]); + k.extend_from_slice(&[b'!', b'l', b'v', 0x00]); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6c, 0x76, 0xff]); + k.extend_from_slice(&[b'!', b'l', b'v', 0xff]); k } impl<'a> Lv<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, lv: Uuid) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x21, // ! - _e: 0x6c, // l - _f: 0x76, // v + _d: b'!', + _e: b'l', + _f: b'v', lv, } } diff --git a/lib/src/key/mod.rs b/lib/src/key/mod.rs index 71d75adf..0e3c7379 100644 --- a/lib/src/key/mod.rs +++ b/lib/src/key/mod.rs @@ -58,3 +58,6 @@ pub mod st; // Stores a DEFINE TOKEN ON SCOPE config definition pub mod table; // Stores the key prefix for all keys under a table pub mod tb; // Stores a DEFINE TABLE config definition pub mod thing; // Stores a record id + +const CHAR_PATH: u8 = 0xb1; // ± +const CHAR_INDEX: u8 = 0xa4; // ¤ diff --git a/lib/src/key/namespace.rs b/lib/src/key/namespace.rs index 74089ed6..99f74816 100644 --- a/lib/src/key/namespace.rs +++ b/lib/src/key/namespace.rs @@ -15,8 +15,8 @@ pub fn new(ns: &str) -> Namespace<'_> { impl<'a> Namespace<'a> { pub fn new(ns: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, } } diff --git a/lib/src/key/nl.rs b/lib/src/key/nl.rs index 081cc8a5..5640635a 100644 --- a/lib/src/key/nl.rs +++ b/lib/src/key/nl.rs @@ -18,25 +18,25 @@ pub fn new<'a>(ns: &'a str, us: &'a str) -> Nl<'a> { pub fn prefix(ns: &str) -> Vec { let mut k = super::namespace::new(ns).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6e, 0x6c, 0x00]); + k.extend_from_slice(&[b'!', b'n', b'l', 0x00]); k } pub fn suffix(ns: &str) -> Vec { let mut k = super::namespace::new(ns).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6e, 0x6c, 0xff]); + k.extend_from_slice(&[b'!', b'n', b'l', 0xff]); k } impl<'a> Nl<'a> { pub fn new(ns: &'a str, us: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x21, // ! - _c: 0x6e, // n - _d: 0x6c, // l + _b: b'!', + _c: b'n', + _d: b'l', us, } } diff --git a/lib/src/key/ns.rs b/lib/src/key/ns.rs index be172f24..1dfca4e4 100644 --- a/lib/src/key/ns.rs +++ b/lib/src/key/ns.rs @@ -16,23 +16,23 @@ pub fn new(ns: &str) -> Ns<'_> { pub fn prefix() -> Vec { let mut k = super::kv::new().encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6e, 0x73, 0x00]); + k.extend_from_slice(&[b'!', b'n', b's', 0x00]); k } pub fn suffix() -> Vec { let mut k = super::kv::new().encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6e, 0x73, 0xff]); + k.extend_from_slice(&[b'!', b'n', b's', 0xff]); k } impl<'a> Ns<'a> { pub fn new(ns: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x21, // ! - _b: 0x6e, // n - _c: 0x73, // s + __: b'/', + _a: b'!', + _b: b'n', + _c: b's', ns, } } diff --git a/lib/src/key/nt.rs b/lib/src/key/nt.rs index f505fc01..d59ed2e4 100644 --- a/lib/src/key/nt.rs +++ b/lib/src/key/nt.rs @@ -18,25 +18,25 @@ pub fn new<'a>(ns: &'a str, tk: &'a str) -> Nt<'a> { pub fn prefix(ns: &str) -> Vec { let mut k = super::namespace::new(ns).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6e, 0x74, 0x00]); + k.extend_from_slice(&[b'!', b'n', b't', 0x00]); k } pub fn suffix(ns: &str) -> Vec { let mut k = super::namespace::new(ns).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x6e, 0x74, 0xff]); + k.extend_from_slice(&[b'!', b'n', b't', 0xff]); k } impl<'a> Nt<'a> { pub fn new(ns: &'a str, tk: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x21, // ! - _c: 0x6e, // n - _d: 0x74, // t + _b: b'!', + _c: b'n', + _d: b't', tk, } } diff --git a/lib/src/key/pa.rs b/lib/src/key/pa.rs index 1e727baa..725a9e00 100644 --- a/lib/src/key/pa.rs +++ b/lib/src/key/pa.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, pa: &'a str) -> Pa<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x70, 0x61, 0x00]); + k.extend_from_slice(&[b'!', b'p', b'a', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x70, 0x61, 0xff]); + k.extend_from_slice(&[b'!', b'p', b'a', 0xff]); k } impl<'a> Pa<'a> { pub fn new(ns: &'a str, db: &'a str, pa: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x70, // p - _e: 0x61, // a + _c: b'!', + _d: b'p', + _e: b'a', pa, } } diff --git a/lib/src/key/sc.rs b/lib/src/key/sc.rs index d92fb93d..80894694 100644 --- a/lib/src/key/sc.rs +++ b/lib/src/key/sc.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, sc: &'a str) -> Sc<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x73, 0x63, 0x00]); + k.extend_from_slice(&[b'!', b's', b'c', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x73, 0x63, 0xff]); + k.extend_from_slice(&[b'!', b's', b'c', 0xff]); k } impl<'a> Sc<'a> { pub fn new(ns: &'a str, db: &'a str, sc: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x73, // s - _e: 0x63, // c + _c: b'!', + _d: b's', + _e: b'c', sc, } } diff --git a/lib/src/key/scope.rs b/lib/src/key/scope.rs index a3b0abb0..71bc14a5 100644 --- a/lib/src/key/scope.rs +++ b/lib/src/key/scope.rs @@ -1,3 +1,4 @@ +use crate::key::CHAR_PATH; use derive::Key; use serde::{Deserialize, Serialize}; @@ -19,12 +20,12 @@ pub fn new<'a>(ns: &'a str, db: &'a str, sc: &'a str) -> Scope<'a> { impl<'a> Scope<'a> { pub fn new(ns: &'a str, db: &'a str, sc: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0xb1, // ± + _c: CHAR_PATH, sc, } } diff --git a/lib/src/key/st.rs b/lib/src/key/st.rs index 3f1675c7..b86593bd 100644 --- a/lib/src/key/st.rs +++ b/lib/src/key/st.rs @@ -1,3 +1,4 @@ +use crate::key::CHAR_PATH; use derive::Key; use serde::{Deserialize, Serialize}; @@ -22,29 +23,29 @@ pub fn new<'a>(ns: &'a str, db: &'a str, sc: &'a str, tk: &'a str) -> St<'a> { pub fn prefix(ns: &str, db: &str, sc: &str) -> Vec { let mut k = super::scope::new(ns, db, sc).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x73, 0x74, 0x00]); + k.extend_from_slice(&[b'!', b's', b't', 0x00]); k } pub fn suffix(ns: &str, db: &str, sc: &str) -> Vec { let mut k = super::scope::new(ns, db, sc).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x73, 0x74, 0xff]); + k.extend_from_slice(&[b'!', b's', b't', 0xff]); k } impl<'a> St<'a> { pub fn new(ns: &'a str, db: &'a str, sc: &'a str, tk: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0xb1, // ± + _c: CHAR_PATH, sc, - _d: 0x21, // ! - _e: 0x73, // s - _f: 0x74, // t + _d: b'!', + _e: b's', + _f: b't', tk, } } diff --git a/lib/src/key/table.rs b/lib/src/key/table.rs index d92b37da..62258cc1 100644 --- a/lib/src/key/table.rs +++ b/lib/src/key/table.rs @@ -19,12 +19,12 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Table<'a> { impl<'a> Table<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, } } diff --git a/lib/src/key/tb.rs b/lib/src/key/tb.rs index bbeb614b..ed6c1433 100644 --- a/lib/src/key/tb.rs +++ b/lib/src/key/tb.rs @@ -20,27 +20,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Tb<'a> { pub fn prefix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x74, 0x62, 0x00]); + k.extend_from_slice(&[b'!', b't', b'b', 0x00]); k } pub fn suffix(ns: &str, db: &str) -> Vec { let mut k = super::database::new(ns, db).encode().unwrap(); - k.extend_from_slice(&[0x21, 0x74, 0x62, 0xff]); + k.extend_from_slice(&[b'!', b't', b'b', 0xff]); k } impl<'a> Tb<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x21, // ! - _d: 0x74, // t - _e: 0x62, // b + _c: b'!', + _d: b't', + _e: b'b', tb, } } diff --git a/lib/src/key/thing.rs b/lib/src/key/thing.rs index db217031..c81cd5f4 100644 --- a/lib/src/key/thing.rs +++ b/lib/src/key/thing.rs @@ -21,27 +21,27 @@ pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, id: &Id) -> Thing<'a> { pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x2a, 0x00]); + k.extend_from_slice(&[b'*', 0x00]); k } pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec { let mut k = super::table::new(ns, db, tb).encode().unwrap(); - k.extend_from_slice(&[0x2a, 0xff]); + k.extend_from_slice(&[b'*', 0xff]); k } impl<'a> Thing<'a> { pub fn new(ns: &'a str, db: &'a str, tb: &'a str, id: Id) -> Self { Self { - __: 0x2f, // / - _a: 0x2a, // * + __: b'/', + _a: b'*', ns, - _b: 0x2a, // * + _b: b'*', db, - _c: 0x2a, // * + _c: b'*', tb, - _d: 0x2a, // * + _d: b'*', id, } }