Ensure all datastore keys encode correctly

This commit is contained in:
Tobie Morgan Hitchcock 2022-05-28 01:02:52 +01:00
parent 56f5f10046
commit 45c81ad02b
20 changed files with 80 additions and 20 deletions

View file

@ -56,7 +56,10 @@ impl Database {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Database, Error> {
Ok(deserialize(v)?)

View file

@ -60,7 +60,10 @@ impl Db {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Db, Error> {
Ok(deserialize(v)?)

View file

@ -64,7 +64,10 @@ impl Dl {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Dl, Error> {
Ok(deserialize(v)?)

View file

@ -64,7 +64,10 @@ impl Dt {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Dt, Error> {
Ok(deserialize(v)?)

View file

@ -68,7 +68,10 @@ impl Ev {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Ev, Error> {
Ok(deserialize(v)?)

View file

@ -68,7 +68,10 @@ impl Fd {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Fd, Error> {
Ok(deserialize(v)?)

View file

@ -68,7 +68,10 @@ impl Ft {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Ft, Error> {
Ok(deserialize(v)?)

View file

@ -64,7 +64,10 @@ impl Guide {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Guide, Error> {
Ok(deserialize(v)?)

View file

@ -68,7 +68,10 @@ impl Ix {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Ix, Error> {
Ok(deserialize(v)?)

View file

@ -42,7 +42,10 @@ impl Kv {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Kv, Error> {
Ok(deserialize::<Kv>(v)?)

View file

@ -68,7 +68,10 @@ impl Lv {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Lv, Error> {
Ok(deserialize(v)?)

View file

@ -52,7 +52,10 @@ impl Namespace {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Namespace, Error> {
Ok(deserialize::<Namespace>(v)?)

View file

@ -60,7 +60,10 @@ impl Nl {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Nl, Error> {
Ok(deserialize(v)?)

View file

@ -56,7 +56,10 @@ impl Ns {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Ns, Error> {
Ok(deserialize::<Ns>(v)?)

View file

@ -60,7 +60,10 @@ impl Nt {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Nt, Error> {
Ok(deserialize(v)?)

View file

@ -64,7 +64,10 @@ impl Sc {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Sc, Error> {
Ok(deserialize(v)?)

View file

@ -72,7 +72,10 @@ impl St {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<St, Error> {
Ok(deserialize(v)?)

View file

@ -60,7 +60,10 @@ impl Table {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Table, Error> {
Ok(deserialize(v)?)

View file

@ -64,7 +64,10 @@ impl Tb {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Tb, Error> {
Ok(deserialize(v)?)

View file

@ -65,7 +65,10 @@ impl Thing {
}
}
pub fn encode(&self) -> Result<Vec<u8>, Error> {
Ok(serialize(self)?)
crate::sql::serde::beg_internal_serialization();
let v = serialize(self);
crate::sql::serde::end_internal_serialization();
Ok(v?)
}
pub fn decode(v: &[u8]) -> Result<Thing, Error> {
Ok(deserialize(v)?)