Rename NU to NL and DU to DL for database keys
This commit is contained in:
parent
1eddf94e8d
commit
f74a619474
4 changed files with 30 additions and 30 deletions
|
@ -4,7 +4,7 @@ use crate::key::BASE;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
pub struct Du {
|
pub struct Dl {
|
||||||
kv: String,
|
kv: String,
|
||||||
_a: String,
|
_a: String,
|
||||||
ns: String,
|
ns: String,
|
||||||
|
@ -14,25 +14,25 @@ pub struct Du {
|
||||||
us: String,
|
us: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Vec<u8>> for Du {
|
impl Into<Vec<u8>> for Dl {
|
||||||
fn into(self) -> Vec<u8> {
|
fn into(self) -> Vec<u8> {
|
||||||
self.encode().unwrap()
|
self.encode().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<u8>> for Du {
|
impl From<Vec<u8>> for Dl {
|
||||||
fn from(val: Vec<u8>) -> Self {
|
fn from(val: Vec<u8>) -> Self {
|
||||||
Du::decode(&val).unwrap()
|
Dl::decode(&val).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(ns: &str, db: &str, us: &str) -> Du {
|
pub fn new(ns: &str, db: &str, us: &str) -> Dl {
|
||||||
Du::new(ns.to_string(), db.to_string(), us.to_string())
|
Dl::new(ns.to_string(), db.to_string(), us.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Du {
|
impl Dl {
|
||||||
pub fn new(ns: String, db: String, us: String) -> Du {
|
pub fn new(ns: String, db: String, us: String) -> Dl {
|
||||||
Du {
|
Dl {
|
||||||
kv: BASE.to_owned(),
|
kv: BASE.to_owned(),
|
||||||
_a: String::from("*"),
|
_a: String::from("*"),
|
||||||
ns,
|
ns,
|
||||||
|
@ -45,7 +45,7 @@ impl Du {
|
||||||
pub fn encode(&self) -> Result<Vec<u8>, Error> {
|
pub fn encode(&self) -> Result<Vec<u8>, Error> {
|
||||||
Ok(serialize(self)?)
|
Ok(serialize(self)?)
|
||||||
}
|
}
|
||||||
pub fn decode(v: &[u8]) -> Result<Du, Error> {
|
pub fn decode(v: &[u8]) -> Result<Dl, Error> {
|
||||||
Ok(deserialize(v)?)
|
Ok(deserialize(v)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,13 @@ mod tests {
|
||||||
fn key() {
|
fn key() {
|
||||||
use super::*;
|
use super::*;
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let val = Du::new(
|
let val = Dl::new(
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
);
|
);
|
||||||
let enc = Du::encode(&val).unwrap();
|
let enc = Dl::encode(&val).unwrap();
|
||||||
let dec = Du::decode(&enc).unwrap();
|
let dec = Dl::decode(&enc).unwrap();
|
||||||
assert_eq!(val, dec);
|
assert_eq!(val, dec);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,10 +46,10 @@ pub const SUFFIX: &'static str = "\x7f";
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
Ns(ns::Ns), // Namespace definition key
|
Ns(ns::Ns), // Namespace definition key
|
||||||
Nt(nt::Nt), // Namespace token definition key
|
Nt(nt::Nt), // Namespace token definition key
|
||||||
Nu(nu::Nu), // Namespace user definition key
|
Nu(nl::Nl), // Namespace login definition key
|
||||||
Db(db::Db), // Database definition key
|
Db(db::Db), // Database definition key
|
||||||
Dt(dt::Dt), // Database token definition key
|
Dt(dt::Dt), // Database token definition key
|
||||||
Du(du::Du), // Database user definition key
|
Du(dl::Dl), // Database login definition key
|
||||||
Sc(sc::Sc), // Scope definition key
|
Sc(sc::Sc), // Scope definition key
|
||||||
St(st::St), // Scope token definition key
|
St(st::St), // Scope token definition key
|
||||||
Tb(tb::Tb), // Table definition key
|
Tb(tb::Tb), // Table definition key
|
||||||
|
|
|
@ -3,8 +3,8 @@ pub use self::key::*;
|
||||||
pub mod bytes;
|
pub mod bytes;
|
||||||
pub mod database;
|
pub mod database;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
|
pub mod dl;
|
||||||
pub mod dt;
|
pub mod dt;
|
||||||
pub mod du;
|
|
||||||
pub mod ev;
|
pub mod ev;
|
||||||
pub mod fd;
|
pub mod fd;
|
||||||
pub mod ft;
|
pub mod ft;
|
||||||
|
@ -14,9 +14,9 @@ pub mod key;
|
||||||
pub mod kv;
|
pub mod kv;
|
||||||
pub mod lv;
|
pub mod lv;
|
||||||
pub mod namespace;
|
pub mod namespace;
|
||||||
|
pub mod nl;
|
||||||
pub mod ns;
|
pub mod ns;
|
||||||
pub mod nt;
|
pub mod nt;
|
||||||
pub mod nu;
|
|
||||||
pub mod point;
|
pub mod point;
|
||||||
pub mod sc;
|
pub mod sc;
|
||||||
pub mod st;
|
pub mod st;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::key::BASE;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
pub struct Nu {
|
pub struct Nl {
|
||||||
kv: String,
|
kv: String,
|
||||||
_a: String,
|
_a: String,
|
||||||
ns: String,
|
ns: String,
|
||||||
|
@ -12,25 +12,25 @@ pub struct Nu {
|
||||||
us: String,
|
us: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Vec<u8>> for Nu {
|
impl Into<Vec<u8>> for Nl {
|
||||||
fn into(self) -> Vec<u8> {
|
fn into(self) -> Vec<u8> {
|
||||||
self.encode().unwrap()
|
self.encode().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Vec<u8>> for Nu {
|
impl From<Vec<u8>> for Nl {
|
||||||
fn from(val: Vec<u8>) -> Self {
|
fn from(val: Vec<u8>) -> Self {
|
||||||
Nu::decode(&val).unwrap()
|
Nl::decode(&val).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(ns: &str, us: &str) -> Nu {
|
pub fn new(ns: &str, us: &str) -> Nl {
|
||||||
Nu::new(ns.to_string(), us.to_string())
|
Nl::new(ns.to_string(), us.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Nu {
|
impl Nl {
|
||||||
pub fn new(ns: String, us: String) -> Nu {
|
pub fn new(ns: String, us: String) -> Nl {
|
||||||
Nu {
|
Nl {
|
||||||
kv: BASE.to_owned(),
|
kv: BASE.to_owned(),
|
||||||
_a: String::from("*"),
|
_a: String::from("*"),
|
||||||
ns,
|
ns,
|
||||||
|
@ -41,7 +41,7 @@ impl Nu {
|
||||||
pub fn encode(&self) -> Result<Vec<u8>, Error> {
|
pub fn encode(&self) -> Result<Vec<u8>, Error> {
|
||||||
Ok(serialize(self)?)
|
Ok(serialize(self)?)
|
||||||
}
|
}
|
||||||
pub fn decode(v: &[u8]) -> Result<Nu, Error> {
|
pub fn decode(v: &[u8]) -> Result<Nl, Error> {
|
||||||
Ok(deserialize(v)?)
|
Ok(deserialize(v)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@ mod tests {
|
||||||
fn key() {
|
fn key() {
|
||||||
use super::*;
|
use super::*;
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let val = Nu::new(
|
let val = Nl::new(
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
);
|
);
|
||||||
let enc = Nu::encode(&val).unwrap();
|
let enc = Nl::encode(&val).unwrap();
|
||||||
let dec = Nu::decode(&enc).unwrap();
|
let dec = Nl::decode(&enc).unwrap();
|
||||||
assert_eq!(val, dec);
|
assert_eq!(val, dec);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue