From f74a619474685afdf465a71a1a34de3a6a9e3db6 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 23 Feb 2022 17:15:49 +0000 Subject: [PATCH] Rename NU to NL and DU to DL for database keys --- lib/src/key/{du.rs => dl.rs} | 26 +++++++++++++------------- lib/src/key/key.rs | 4 ++-- lib/src/key/mod.rs | 4 ++-- lib/src/key/{nu.rs => nl.rs} | 26 +++++++++++++------------- 4 files changed, 30 insertions(+), 30 deletions(-) rename lib/src/key/{du.rs => dl.rs} (65%) rename lib/src/key/{nu.rs => nl.rs} (65%) diff --git a/lib/src/key/du.rs b/lib/src/key/dl.rs similarity index 65% rename from lib/src/key/du.rs rename to lib/src/key/dl.rs index d3348c0e..af878758 100644 --- a/lib/src/key/du.rs +++ b/lib/src/key/dl.rs @@ -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> for Du { +impl Into> for Dl { fn into(self) -> Vec { self.encode().unwrap() } } -impl From> for Du { +impl From> for Dl { fn from(val: Vec) -> 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, Error> { Ok(serialize(self)?) } - pub fn decode(v: &[u8]) -> Result { + pub fn decode(v: &[u8]) -> Result { 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); } } diff --git a/lib/src/key/key.rs b/lib/src/key/key.rs index 23c58fdb..e4413cac 100644 --- a/lib/src/key/key.rs +++ b/lib/src/key/key.rs @@ -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 diff --git a/lib/src/key/mod.rs b/lib/src/key/mod.rs index a69e0cda..3a8cca77 100644 --- a/lib/src/key/mod.rs +++ b/lib/src/key/mod.rs @@ -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; diff --git a/lib/src/key/nu.rs b/lib/src/key/nl.rs similarity index 65% rename from lib/src/key/nu.rs rename to lib/src/key/nl.rs index 35b035ec..052de095 100644 --- a/lib/src/key/nu.rs +++ b/lib/src/key/nl.rs @@ -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> for Nu { +impl Into> for Nl { fn into(self) -> Vec { self.encode().unwrap() } } -impl From> for Nu { +impl From> for Nl { fn from(val: Vec) -> 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, Error> { Ok(serialize(self)?) } - pub fn decode(v: &[u8]) -> Result { + pub fn decode(v: &[u8]) -> Result { 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); } }