Optimization - Zero copy key deserialization. (#1880)
This commit is contained in:
parent
59947749e3
commit
c295cb0509
29 changed files with 371 additions and 351 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -3710,11 +3710,12 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||
|
||||
[[package]]
|
||||
name = "storekey"
|
||||
version = "0.4.1"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "475592c1aa8849fa7874777c9df46aa93ffc47851c7c60bee88b1745a1adb893"
|
||||
checksum = "43c42833834a5d23b344f71d87114e0cc9994766a5c42938f4b50e7b2aef85b2"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"memchr",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
|
|
@ -92,7 +92,7 @@ serde = { version = "1.0.160", features = ["derive"] }
|
|||
serde_json = "1.0.96"
|
||||
sha-1 = "0.10.1"
|
||||
sha2 = "0.10.6"
|
||||
storekey = "0.4.1"
|
||||
storekey = "0.5.0"
|
||||
thiserror = "1.0.40"
|
||||
tikv = { version = "0.1.0", package = "tikv-client", optional = true }
|
||||
tokio-util = { version = "0.7.7", optional = true, features = ["compat"] }
|
||||
|
|
|
@ -2,21 +2,21 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Database {
|
||||
pub struct Database<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str) -> Database {
|
||||
Database::new(ns.to_string(), db.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str) -> Database<'a> {
|
||||
Database::new(ns, db)
|
||||
}
|
||||
|
||||
impl Database {
|
||||
pub fn new(ns: String, db: String) -> Database {
|
||||
Database {
|
||||
impl<'a> Database<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -33,8 +33,8 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Database::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Database::encode(&val).unwrap();
|
||||
let dec = Database::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,18 +2,18 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Db {
|
||||
pub struct Db<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str) -> Db {
|
||||
Db::new(ns.to_string(), db.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str) -> Db<'a> {
|
||||
Db::new(ns, db)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str) -> Vec<u8> {
|
||||
|
@ -28,9 +28,9 @@ pub fn suffix(ns: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Db {
|
||||
pub fn new(ns: String, db: String) -> Db {
|
||||
Db {
|
||||
impl<'a> Db<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -49,8 +49,8 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Db::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Db::encode(&val).unwrap();
|
||||
let dec = Db::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,20 +2,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Dl {
|
||||
pub struct Dl<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub dl: String,
|
||||
pub dl: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, dl: &str) -> Dl {
|
||||
Dl::new(ns.to_string(), db.to_string(), dl.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, dl: &'a str) -> Dl<'a> {
|
||||
Dl::new(ns, db, dl)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str) -> Vec<u8> {
|
||||
|
@ -30,9 +30,9 @@ pub fn suffix(ns: &str, db: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Dl {
|
||||
pub fn new(ns: String, db: String, dl: String) -> Dl {
|
||||
Dl {
|
||||
impl<'a> Dl<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, dl: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Dl::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Dl::encode(&val).unwrap();
|
||||
let dec = Dl::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,20 +2,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Dt {
|
||||
pub struct Dt<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub tk: String,
|
||||
pub tk: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str) -> Dt {
|
||||
Dt::new(ns.to_string(), db.to_string(), tb.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Dt<'a> {
|
||||
Dt::new(ns, db, tb)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str) -> Vec<u8> {
|
||||
|
@ -30,9 +30,9 @@ pub fn suffix(ns: &str, db: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Dt {
|
||||
pub fn new(ns: String, db: String, tk: String) -> Dt {
|
||||
Dt {
|
||||
impl<'a> Dt<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tk: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Dt::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Dt::encode(&val).unwrap();
|
||||
let dec = Dt::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,22 +2,22 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Ev {
|
||||
pub struct Ev<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
_f: u8,
|
||||
pub ev: String,
|
||||
pub ev: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, ev: &str) -> Ev {
|
||||
Ev::new(ns.to_string(), db.to_string(), tb.to_string(), ev.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ev: &'a str) -> Ev<'a> {
|
||||
Ev::new(ns, db, tb, ev)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
||||
|
@ -32,9 +32,9 @@ pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Ev {
|
||||
pub fn new(ns: String, db: String, tb: String, ev: String) -> Ev {
|
||||
Ev {
|
||||
impl<'a> Ev<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str, ev: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -57,10 +57,10 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Ev::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Ev::encode(&val).unwrap();
|
||||
let dec = Ev::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,20 +2,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Fc {
|
||||
pub struct Fc<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub fc: String,
|
||||
pub fc: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, fc: &str) -> Fc {
|
||||
Fc::new(ns.to_string(), db.to_string(), fc.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, fc: &'a str) -> Fc<'a> {
|
||||
Fc::new(ns, db, fc)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str) -> Vec<u8> {
|
||||
|
@ -30,9 +30,9 @@ pub fn suffix(ns: &str, db: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Fc {
|
||||
pub fn new(ns: String, db: String, fc: String) -> Fc {
|
||||
Fc {
|
||||
impl<'a> Fc<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, fc: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Fc::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Fc::encode(&val).unwrap();
|
||||
let dec = Fc::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,22 +2,22 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Fd {
|
||||
pub struct Fd<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
_f: u8,
|
||||
pub fd: String,
|
||||
pub fd: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, fd: &str) -> Fd {
|
||||
Fd::new(ns.to_string(), db.to_string(), tb.to_string(), fd.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, fd: &'a str) -> Fd<'a> {
|
||||
Fd::new(ns, db, tb, fd)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
||||
|
@ -32,9 +32,9 @@ pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Fd {
|
||||
pub fn new(ns: String, db: String, tb: String, fd: String) -> Fd {
|
||||
Fd {
|
||||
impl<'a> Fd<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str, fd: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -57,10 +57,10 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Fd::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Fd::encode(&val).unwrap();
|
||||
let dec = Fd::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,22 +2,22 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Ft {
|
||||
pub struct Ft<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
_f: u8,
|
||||
pub ft: String,
|
||||
pub ft: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, ft: &str) -> Ft {
|
||||
Ft::new(ns.to_string(), db.to_string(), tb.to_string(), ft.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ft: &'a str) -> Ft<'a> {
|
||||
Ft::new(ns, db, tb, ft)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
||||
|
@ -32,9 +32,9 @@ pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Ft {
|
||||
pub fn new(ns: String, db: String, tb: String, ft: String) -> Ft {
|
||||
Ft {
|
||||
impl<'a> Ft<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str, ft: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -57,10 +57,10 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Ft::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Ft::encode(&val).unwrap();
|
||||
let dec = Ft::decode(&enc).unwrap();
|
||||
|
|
|
@ -5,28 +5,28 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
struct Prefix {
|
||||
struct Prefix<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub id: Id,
|
||||
}
|
||||
|
||||
impl Prefix {
|
||||
fn new(ns: &str, db: &str, tb: &str, id: &Id) -> Prefix {
|
||||
Prefix {
|
||||
impl<'a> Prefix<'a> {
|
||||
fn new(ns: &'a str, db: &'a str, tb: &'a str, id: &Id) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns: ns.to_string(),
|
||||
ns,
|
||||
_b: 0x2a, // *
|
||||
db: db.to_string(),
|
||||
db,
|
||||
_c: 0x2a, // *
|
||||
tb: tb.to_string(),
|
||||
tb,
|
||||
_d: 0x7e, // ~
|
||||
id: id.to_owned(),
|
||||
}
|
||||
|
@ -34,29 +34,29 @@ impl Prefix {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
struct PrefixEg {
|
||||
struct PrefixEg<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub id: Id,
|
||||
pub eg: Dir,
|
||||
}
|
||||
|
||||
impl PrefixEg {
|
||||
fn new(ns: &str, db: &str, tb: &str, id: &Id, eg: &Dir) -> PrefixEg {
|
||||
PrefixEg {
|
||||
impl<'a> PrefixEg<'a> {
|
||||
fn new(ns: &'a str, db: &'a str, tb: &'a str, id: &Id, eg: &Dir) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns: ns.to_string(),
|
||||
ns,
|
||||
_b: 0x2a, // *
|
||||
db: db.to_string(),
|
||||
db,
|
||||
_c: 0x2a, // *
|
||||
tb: tb.to_string(),
|
||||
tb,
|
||||
_d: 0x7e, // ~
|
||||
id: id.to_owned(),
|
||||
eg: eg.to_owned(),
|
||||
|
@ -65,63 +65,63 @@ impl PrefixEg {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
struct PrefixFt {
|
||||
struct PrefixFt<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub id: Id,
|
||||
pub eg: Dir,
|
||||
pub ft: String,
|
||||
pub ft: &'a str,
|
||||
}
|
||||
|
||||
impl PrefixFt {
|
||||
fn new(ns: &str, db: &str, tb: &str, id: &Id, eg: &Dir, ft: &str) -> PrefixFt {
|
||||
PrefixFt {
|
||||
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, // *
|
||||
ns: ns.to_string(),
|
||||
ns,
|
||||
_b: 0x2a, // *
|
||||
db: db.to_string(),
|
||||
db,
|
||||
_c: 0x2a, // *
|
||||
tb: tb.to_string(),
|
||||
tb,
|
||||
_d: 0x7e, // ~
|
||||
id: id.to_owned(),
|
||||
eg: eg.to_owned(),
|
||||
ft: ft.to_string(),
|
||||
ft,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Graph {
|
||||
pub struct Graph<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub id: Id,
|
||||
pub eg: Dir,
|
||||
pub ft: String,
|
||||
pub ft: &'a str,
|
||||
pub fk: Id,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, id: &Id, eg: &Dir, fk: &Thing) -> Graph {
|
||||
Graph::new(
|
||||
ns.to_string(),
|
||||
db.to_string(),
|
||||
tb.to_string(),
|
||||
id.to_owned(),
|
||||
eg.to_owned(),
|
||||
fk.to_owned(),
|
||||
)
|
||||
pub fn new<'a>(
|
||||
ns: &'a str,
|
||||
db: &'a str,
|
||||
tb: &'a str,
|
||||
id: &Id,
|
||||
eg: &Dir,
|
||||
fk: &'a Thing,
|
||||
) -> Graph<'a> {
|
||||
Graph::new(ns, db, tb, id.to_owned(), eg.to_owned(), fk)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str, id: &Id) -> Vec<u8> {
|
||||
|
@ -160,9 +160,9 @@ pub fn ftsuffix(ns: &str, db: &str, tb: &str, id: &Id, eg: &Dir, ft: &str) -> Ve
|
|||
k
|
||||
}
|
||||
|
||||
impl Graph {
|
||||
pub fn new(ns: String, db: String, tb: String, id: Id, eg: Dir, fk: Thing) -> Graph {
|
||||
Graph {
|
||||
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, // *
|
||||
ns,
|
||||
|
@ -173,8 +173,8 @@ impl Graph {
|
|||
_d: 0x7e, // ~
|
||||
id,
|
||||
eg,
|
||||
ft: fk.tb,
|
||||
fk: fk.id,
|
||||
ft: &fk.tb,
|
||||
fk: fk.id.to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,14 +185,15 @@ mod tests {
|
|||
fn key() {
|
||||
use super::*;
|
||||
use crate::sql::test::Parse;
|
||||
let fk = Thing::parse("other:test");
|
||||
#[rustfmt::skip]
|
||||
let val = Graph::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test".into(),
|
||||
Dir::Out,
|
||||
Thing::parse("other:test"),
|
||||
&fk,
|
||||
);
|
||||
let enc = Graph::encode(&val).unwrap();
|
||||
let dec = Graph::decode(&enc).unwrap();
|
||||
|
|
|
@ -4,58 +4,58 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
struct Prefix {
|
||||
struct Prefix<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub ix: String,
|
||||
pub ix: &'a str,
|
||||
}
|
||||
|
||||
impl Prefix {
|
||||
fn new(ns: &str, db: &str, tb: &str, ix: &str) -> Prefix {
|
||||
Prefix {
|
||||
impl<'a> Prefix<'a> {
|
||||
fn new(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns: ns.to_string(),
|
||||
ns,
|
||||
_b: 0x2a, // *
|
||||
db: db.to_string(),
|
||||
db,
|
||||
_c: 0x2a, // *
|
||||
tb: tb.to_string(),
|
||||
tb,
|
||||
_d: 0xa4, // ¤
|
||||
ix: ix.to_string(),
|
||||
ix,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Index {
|
||||
pub struct Index<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub ix: String,
|
||||
pub ix: &'a str,
|
||||
pub fd: Array,
|
||||
pub id: Option<Id>,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, ix: &str, fd: &Array, id: Option<&Id>) -> Index {
|
||||
Index::new(
|
||||
ns.to_string(),
|
||||
db.to_string(),
|
||||
tb.to_string(),
|
||||
ix.to_string(),
|
||||
fd.to_owned(),
|
||||
id.cloned(),
|
||||
)
|
||||
pub fn new<'a>(
|
||||
ns: &'a str,
|
||||
db: &'a str,
|
||||
tb: &'a str,
|
||||
ix: &'a str,
|
||||
fd: &Array,
|
||||
id: Option<&Id>,
|
||||
) -> Index<'a> {
|
||||
Index::new(ns, db, tb, ix, fd.to_owned(), id.cloned())
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str, ix: &str) -> Vec<u8> {
|
||||
|
@ -70,9 +70,16 @@ pub fn suffix(ns: &str, db: &str, tb: &str, ix: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Index {
|
||||
pub fn new(ns: String, db: String, tb: String, ix: String, fd: Array, id: Option<Id>) -> Index {
|
||||
Index {
|
||||
impl<'a> Index<'a> {
|
||||
pub fn new(
|
||||
ns: &'a str,
|
||||
db: &'a str,
|
||||
tb: &'a str,
|
||||
ix: &'a str,
|
||||
fd: Array,
|
||||
id: Option<Id>,
|
||||
) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -95,10 +102,10 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Index::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
vec!["test"].into(),
|
||||
Some("test".into()),
|
||||
);
|
||||
|
|
|
@ -2,22 +2,22 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Ix {
|
||||
pub struct Ix<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
_f: u8,
|
||||
pub ix: String,
|
||||
pub ix: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, ix: &str) -> Ix {
|
||||
Ix::new(ns.to_string(), db.to_string(), tb.to_string(), ix.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Ix<'a> {
|
||||
Ix::new(ns, db, tb, ix)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
||||
|
@ -32,9 +32,9 @@ pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Ix {
|
||||
pub fn new(ns: String, db: String, tb: String, ix: String) -> Ix {
|
||||
Ix {
|
||||
impl<'a> Ix<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str, ix: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -57,10 +57,10 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Ix::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Ix::encode(&val).unwrap();
|
||||
let dec = Ix::decode(&enc).unwrap();
|
||||
|
|
|
@ -3,25 +3,25 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Lq {
|
||||
pub struct Lq<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub lq: Uuid,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, lq: &Uuid) -> Lq {
|
||||
Lq::new(ns.to_string(), db.to_string(), lq.to_owned())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, lq: &Uuid) -> Lq<'a> {
|
||||
Lq::new(ns, db, lq.to_owned())
|
||||
}
|
||||
|
||||
impl Lq {
|
||||
pub fn new(ns: String, db: String, lq: Uuid) -> Lq {
|
||||
Lq {
|
||||
impl<'a> Lq<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, lq: Uuid) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -42,8 +42,8 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Lq::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
Uuid::default(),
|
||||
);
|
||||
let enc = Lq::encode(&val).unwrap();
|
||||
|
|
|
@ -3,22 +3,22 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Lv {
|
||||
pub struct Lv<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
_f: u8,
|
||||
pub lv: Uuid,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, lv: &Uuid) -> Lv {
|
||||
Lv::new(ns.to_string(), db.to_string(), tb.to_string(), lv.to_owned())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, lv: &Uuid) -> Lv<'a> {
|
||||
Lv::new(ns, db, tb, lv.to_owned())
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
||||
|
@ -33,9 +33,9 @@ pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Lv {
|
||||
pub fn new(ns: String, db: String, tb: String, lv: Uuid) -> Lv {
|
||||
Lv {
|
||||
impl<'a> Lv<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str, lv: Uuid) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -58,9 +58,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Lv::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
Uuid::default(),
|
||||
);
|
||||
let enc = Lv::encode(&val).unwrap();
|
||||
|
|
|
@ -2,19 +2,19 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Namespace {
|
||||
pub struct Namespace<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str) -> Namespace {
|
||||
Namespace::new(ns.to_string())
|
||||
pub fn new<'a>(ns: &'a str) -> Namespace<'a> {
|
||||
Namespace::new(ns)
|
||||
}
|
||||
|
||||
impl Namespace {
|
||||
pub fn new(ns: String) -> Namespace {
|
||||
Namespace {
|
||||
impl<'a> Namespace<'a> {
|
||||
pub fn new(ns: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -29,7 +29,7 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Namespace::new(
|
||||
"test".to_string(),
|
||||
"test",
|
||||
);
|
||||
let enc = Namespace::encode(&val).unwrap();
|
||||
let dec = Namespace::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,18 +2,18 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Nl {
|
||||
pub struct Nl<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
pub us: String,
|
||||
pub us: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, us: &str) -> Nl {
|
||||
Nl::new(ns.to_string(), us.to_string())
|
||||
pub fn new<'a>(ns: &'a str, us: &'a str) -> Nl<'a> {
|
||||
Nl::new(ns, us)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str) -> Vec<u8> {
|
||||
|
@ -28,9 +28,9 @@ pub fn suffix(ns: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Nl {
|
||||
pub fn new(ns: String, us: String) -> Nl {
|
||||
Nl {
|
||||
impl<'a> Nl<'a> {
|
||||
pub fn new(ns: &'a str, us: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -49,8 +49,8 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Nl::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Nl::encode(&val).unwrap();
|
||||
let dec = Nl::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,16 +2,16 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Ns {
|
||||
pub struct Ns<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
_b: u8,
|
||||
_c: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str) -> Ns {
|
||||
Ns::new(ns.to_string())
|
||||
pub fn new<'a>(ns: &'a str) -> Ns<'a> {
|
||||
Ns::new(ns)
|
||||
}
|
||||
|
||||
pub fn prefix() -> Vec<u8> {
|
||||
|
@ -26,9 +26,9 @@ pub fn suffix() -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Ns {
|
||||
pub fn new(ns: String) -> Ns {
|
||||
Ns {
|
||||
impl<'a> Ns<'a> {
|
||||
pub fn new(ns: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x21, // !
|
||||
_b: 0x6e, // n
|
||||
|
@ -45,7 +45,7 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Ns::new(
|
||||
"test".to_string(),
|
||||
"test",
|
||||
);
|
||||
let enc = Ns::encode(&val).unwrap();
|
||||
let dec = Ns::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,18 +2,18 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Nt {
|
||||
pub struct Nt<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
pub tk: String,
|
||||
pub tk: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, tk: &str) -> Nt {
|
||||
Nt::new(ns.to_string(), tk.to_string())
|
||||
pub fn new<'a>(ns: &'a str, tk: &'a str) -> Nt<'a> {
|
||||
Nt::new(ns, tk)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str) -> Vec<u8> {
|
||||
|
@ -28,9 +28,9 @@ pub fn suffix(ns: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Nt {
|
||||
pub fn new(ns: String, tk: String) -> Nt {
|
||||
Nt {
|
||||
impl<'a> Nt<'a> {
|
||||
pub fn new(ns: &'a str, tk: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -49,8 +49,8 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Nt::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Nt::encode(&val).unwrap();
|
||||
let dec = Nt::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,20 +2,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Pa {
|
||||
pub struct Pa<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub pa: String,
|
||||
pub pa: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, pa: &str) -> Pa {
|
||||
Pa::new(ns.to_string(), db.to_string(), pa.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, pa: &'a str) -> Pa<'a> {
|
||||
Pa::new(ns, db, pa)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str) -> Vec<u8> {
|
||||
|
@ -30,9 +30,9 @@ pub fn suffix(ns: &str, db: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Pa {
|
||||
pub fn new(ns: String, db: String, pa: String) -> Pa {
|
||||
Pa {
|
||||
impl<'a> Pa<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, pa: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Pa::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Pa::encode(&val).unwrap();
|
||||
let dec = Pa::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,20 +2,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Sc {
|
||||
pub struct Sc<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub sc: String,
|
||||
pub sc: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, sc: &str) -> Sc {
|
||||
Sc::new(ns.to_string(), db.to_string(), sc.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, sc: &'a str) -> Sc<'a> {
|
||||
Sc::new(ns, db, sc)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str) -> Vec<u8> {
|
||||
|
@ -30,9 +30,9 @@ pub fn suffix(ns: &str, db: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Sc {
|
||||
pub fn new(ns: String, db: String, sc: String) -> Sc {
|
||||
Sc {
|
||||
impl<'a> Sc<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, sc: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Sc::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Sc::encode(&val).unwrap();
|
||||
let dec = Sc::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,23 +2,23 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Scope {
|
||||
pub struct Scope<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub sc: String,
|
||||
pub sc: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, sc: &str) -> Scope {
|
||||
Scope::new(ns.to_string(), db.to_string(), sc.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, sc: &'a str) -> Scope<'a> {
|
||||
Scope::new(ns, db, sc)
|
||||
}
|
||||
|
||||
impl Scope {
|
||||
pub fn new(ns: String, db: String, sc: String) -> Scope {
|
||||
Scope {
|
||||
impl<'a> Scope<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, sc: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -37,9 +37,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Scope::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Scope::encode(&val).unwrap();
|
||||
let dec = Scope::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,22 +2,22 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct St {
|
||||
pub struct St<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub sc: String,
|
||||
pub sc: &'a str,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
_f: u8,
|
||||
pub tk: String,
|
||||
pub tk: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, sc: &str, tk: &str) -> St {
|
||||
St::new(ns.to_string(), db.to_string(), sc.to_string(), tk.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, sc: &'a str, tk: &'a str) -> St<'a> {
|
||||
St::new(ns, db, sc, tk)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, sc: &str) -> Vec<u8> {
|
||||
|
@ -32,9 +32,9 @@ pub fn suffix(ns: &str, db: &str, sc: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl St {
|
||||
pub fn new(ns: String, db: String, sc: String, tk: String) -> St {
|
||||
St {
|
||||
impl<'a> St<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, sc: &'a str, tk: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -57,10 +57,10 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = St::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = St::encode(&val).unwrap();
|
||||
let dec = St::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,23 +2,23 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Table {
|
||||
pub struct Table<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str) -> Table {
|
||||
Table::new(ns.to_string(), db.to_string(), tb.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Table<'a> {
|
||||
Table::new(ns, db, tb)
|
||||
}
|
||||
|
||||
impl Table {
|
||||
pub fn new(ns: String, db: String, tb: String) -> Table {
|
||||
Table {
|
||||
impl<'a> Table<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -37,9 +37,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Table::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Table::encode(&val).unwrap();
|
||||
let dec = Table::decode(&enc).unwrap();
|
||||
|
|
|
@ -2,20 +2,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Tb {
|
||||
pub struct Tb<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
_d: u8,
|
||||
_e: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str) -> Tb {
|
||||
Tb::new(ns.to_string(), db.to_string(), tb.to_string())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str) -> Tb<'a> {
|
||||
Tb::new(ns, db, tb)
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str) -> Vec<u8> {
|
||||
|
@ -30,9 +30,9 @@ pub fn suffix(ns: &str, db: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Tb {
|
||||
pub fn new(ns: String, db: String, tb: String) -> Tb {
|
||||
Tb {
|
||||
impl<'a> Tb<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -53,9 +53,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Tb::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
let enc = Tb::encode(&val).unwrap();
|
||||
let dec = Tb::decode(&enc).unwrap();
|
||||
|
|
|
@ -3,20 +3,20 @@ use derive::Key;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Key)]
|
||||
pub struct Thing {
|
||||
pub struct Thing<'a> {
|
||||
__: u8,
|
||||
_a: u8,
|
||||
pub ns: String,
|
||||
pub ns: &'a str,
|
||||
_b: u8,
|
||||
pub db: String,
|
||||
pub db: &'a str,
|
||||
_c: u8,
|
||||
pub tb: String,
|
||||
pub tb: &'a str,
|
||||
_d: u8,
|
||||
pub id: Id,
|
||||
}
|
||||
|
||||
pub fn new(ns: &str, db: &str, tb: &str, id: &Id) -> Thing {
|
||||
Thing::new(ns.to_string(), db.to_string(), tb.to_string(), id.to_owned())
|
||||
pub fn new<'a>(ns: &'a str, db: &'a str, tb: &'a str, id: &Id) -> Thing<'a> {
|
||||
Thing::new(ns, db, tb, id.to_owned())
|
||||
}
|
||||
|
||||
pub fn prefix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
||||
|
@ -31,9 +31,9 @@ pub fn suffix(ns: &str, db: &str, tb: &str) -> Vec<u8> {
|
|||
k
|
||||
}
|
||||
|
||||
impl Thing {
|
||||
pub fn new(ns: String, db: String, tb: String, id: Id) -> Thing {
|
||||
Thing {
|
||||
impl<'a> Thing<'a> {
|
||||
pub fn new(ns: &'a str, db: &'a str, tb: &'a str, id: Id) -> Self {
|
||||
Self {
|
||||
__: 0x2f, // /
|
||||
_a: 0x2a, // *
|
||||
ns,
|
||||
|
@ -54,9 +54,9 @@ mod tests {
|
|||
use super::*;
|
||||
#[rustfmt::skip]
|
||||
let val = Thing::new(
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test".to_string(),
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
"test".into(),
|
||||
);
|
||||
let enc = Thing::encode(&val).unwrap();
|
||||
|
@ -69,7 +69,7 @@ mod tests {
|
|||
//
|
||||
let id1 = "['test']";
|
||||
let (_, id1) = crate::sql::id::id(id1).expect("Failed to parse the ID");
|
||||
let val = Thing::new("test".to_string(), "test".to_string(), "test".to_string(), id1);
|
||||
let val = Thing::new("test", "test", "test", id1);
|
||||
let enc = Thing::encode(&val).unwrap();
|
||||
let dec = Thing::decode(&enc).unwrap();
|
||||
assert_eq!(val, dec);
|
||||
|
@ -77,7 +77,7 @@ mod tests {
|
|||
//
|
||||
let id2 = "['f8e238f2-e734-47b8-9a16-476b291bd78a']";
|
||||
let (_, id2) = crate::sql::id::id(id2).expect("Failed to parse the ID");
|
||||
let val = Thing::new("test".to_string(), "test".to_string(), "test".to_string(), id2);
|
||||
let val = Thing::new("test", "test", "test", id2);
|
||||
let enc = Thing::encode(&val).unwrap();
|
||||
let dec = Thing::decode(&enc).unwrap();
|
||||
assert_eq!(val, dec);
|
||||
|
|
|
@ -1035,7 +1035,8 @@ impl DefineFieldStatement {
|
|||
// Claim transaction
|
||||
let mut run = run.lock().await;
|
||||
// Process the statement
|
||||
let key = crate::key::fd::new(opt.ns(), opt.db(), &self.what, &self.name.to_string());
|
||||
let fd = self.name.to_string();
|
||||
let key = crate::key::fd::new(opt.ns(), opt.db(), &self.what, &fd);
|
||||
run.add_ns(opt.ns(), opt.strict).await?;
|
||||
run.add_db(opt.ns(), opt.db(), opt.strict).await?;
|
||||
run.add_tb(opt.ns(), opt.db(), &self.what, opt.strict).await?;
|
||||
|
|
|
@ -707,7 +707,8 @@ impl RemoveFieldStatement {
|
|||
// Claim transaction
|
||||
let mut run = run.lock().await;
|
||||
// Delete the definition
|
||||
let key = crate::key::fd::new(opt.ns(), opt.db(), &self.what, &self.name.to_string());
|
||||
let fd = self.name.to_string();
|
||||
let key = crate::key::fd::new(opt.ns(), opt.db(), &self.what, &fd);
|
||||
run.del(key).await?;
|
||||
// Clear the cache
|
||||
let key = crate::key::fd::prefix(opt.ns(), opt.db(), &self.what);
|
||||
|
|
|
@ -27,6 +27,15 @@ pub struct Thing {
|
|||
pub id: Id,
|
||||
}
|
||||
|
||||
impl From<(&str, Id)> for Thing {
|
||||
fn from((tb, id): (&str, Id)) -> Self {
|
||||
Self {
|
||||
tb: tb.to_owned(),
|
||||
id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(String, Id)> for Thing {
|
||||
fn from((tb, id): (String, Id)) -> Self {
|
||||
Self {
|
||||
|
|
Loading…
Reference in a new issue