From 0431d386021fc587b3eb35190ce4b88acc35fe92 Mon Sep 17 00:00:00 2001 From: Micha de Vries Date: Mon, 15 Jan 2024 12:36:13 +0100 Subject: [PATCH] Update CBOR tags (#3312) --- src/rpc/format/cbor/convert.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/rpc/format/cbor/convert.rs b/src/rpc/format/cbor/convert.rs index ce437e34..2a96de7e 100644 --- a/src/rpc/format/cbor/convert.rs +++ b/src/rpc/format/cbor/convert.rs @@ -8,12 +8,12 @@ use surrealdb::sql::Thing; use surrealdb::sql::Uuid; use surrealdb::sql::Value; -const TAG_NONE: u64 = 78_773_250; -const TAG_UUID: u64 = 78_773_251; -const TAG_DECIMAL: u64 = 78_773_252; -const TAG_DURATION: u64 = 78_773_253; -const TAG_DATETIME: u64 = 78_773_254; -const TAG_RECORDID: u64 = 78_773_255; +const TAG_DATETIME: u64 = 0; +const TAG_NONE: u64 = 6; +const TAG_UUID: u64 = 7; +const TAG_DECIMAL: u64 = 8; +const TAG_DURATION: u64 = 9; +const TAG_RECORDID: u64 = 10; #[derive(Debug)] pub struct Cbor(pub Data); @@ -41,6 +41,14 @@ impl TryFrom for Value { .collect::>(), Data::Tag(t, v) => { match t { + // A literal datetime + TAG_DATETIME => match *v { + Data::Text(v) => match Datetime::try_from(v) { + Ok(v) => Ok(v.into()), + _ => Err("Expected a valid Datetime value"), + }, + _ => Err("Expected a CBOR text data type"), + }, // A literal NONE TAG_NONE => Ok(Value::None), // A literal uuid @@ -67,14 +75,6 @@ impl TryFrom for Value { }, _ => Err("Expected a CBOR text data type"), }, - // A literal datetime - TAG_DATETIME => match *v { - Data::Text(v) => match Datetime::try_from(v) { - Ok(v) => Ok(v.into()), - _ => Err("Expected a valid Datetime value"), - }, - _ => Err("Expected a CBOR text data type"), - }, // A literal recordid TAG_RECORDID => match *v { Data::Text(v) => match Thing::try_from(v) {