Favour rust binary characters instead of hex (#1978)

This commit is contained in:
Przemyslaw Hugh Kaznowski 2023-05-13 00:40:45 +01:00 committed by GitHub
parent 8780bbda9c
commit df745bb3a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 200 additions and 194 deletions

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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,
}
}

View file

@ -18,25 +18,25 @@ pub fn new<'a>(ns: &'a str, db: &'a str) -> Db<'a> {
pub fn prefix(ns: &str) -> Vec<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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,

View file

@ -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<Id>,
) -> 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,

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -19,7 +19,7 @@ impl Default for Kv {
impl Kv {
pub fn new() -> Kv {
Kv {
__: 0x2f, // /
__: b'/',
}
}
}

View file

@ -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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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; // ¤

View file

@ -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,
}
}

View file

@ -18,25 +18,25 @@ pub fn new<'a>(ns: &'a str, us: &'a str) -> Nl<'a> {
pub fn prefix(ns: &str) -> Vec<u8> {
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<u8> {
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,
}
}

View file

@ -16,23 +16,23 @@ pub fn new(ns: &str) -> Ns<'_> {
pub fn prefix() -> Vec<u8> {
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<u8> {
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,
}
}

View file

@ -18,25 +18,25 @@ pub fn new<'a>(ns: &'a str, tk: &'a str) -> Nt<'a> {
pub fn prefix(ns: &str) -> Vec<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}

View file

@ -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<u8> {
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<u8> {
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,
}
}