From ec0e09da4f37b1f5c095aeb05063d1465a33c831 Mon Sep 17 00:00:00 2001 From: Dharshan Date: Fri, 10 Jan 2025 19:55:34 +0530 Subject: [PATCH] Changed uuid4str, uuid7 and uuid7ts to external functions. --- core/ext/uuid.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/ext/uuid.rs b/core/ext/uuid.rs index 92fdd831..40588466 100644 --- a/core/ext/uuid.rs +++ b/core/ext/uuid.rs @@ -71,6 +71,22 @@ pub fn exec_uuid4() -> crate::Result { ))) } +pub fn exec_uuid4str() -> crate::Result { + Ok(OwnedValue::Text(LimboText::new(Rc::new(Uuid::new_v4().to_string())))) +} + +pub fn exec_uuid7() -> crate::Result { + Ok(OwnedValue::Blob(Rc::new(Uuid::new_v7(Timestamp::now(ContextV7::new())).into_bytes().to_vec()))) +} + +pub fn exec_uuid7_ts(ref seconds) -> crate::Result { + if(*seconds < 0){ + return Ok(OwnedValue::Null); + } + let ctx = ContextV7::new(); + Ok(OwnedValue::Blob(Rc::new(Uuid::new_v7(Timestamp::from_unix(ctx, *seconds as u64, 0)).into_bytes().to_vec()))) +} + pub fn exec_uuidstr(reg: &OwnedValue) -> crate::Result { match reg { OwnedValue::Blob(blob) => {