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