Drop uuid_unstable as it is no longer necessary (#3009)

This commit is contained in:
Rushmore Mushambi 2023-11-20 19:42:44 +02:00 committed by GitHub
parent 2584970b1d
commit 7d75fe1877
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 29 deletions

View file

@ -1,18 +1,13 @@
[build]
rustflags = ["--cfg", "uuid_unstable"]
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.x86_64-unknown-linux-musl]
rustflags = [
"--cfg", "uuid_unstable",
"-C", "target-feature=+crt-static"
]
[target.x86_64-pc-windows-msvc]
rustflags = [
"--cfg", "uuid_unstable",
"-C", "target-feature=+crt-static",
"-C", "link-arg=/NODEFAULTLIB:libvcruntimed.lib",
"-C", "link-arg=/NODEFAULTLIB:vcruntime.lib",

View file

@ -168,15 +168,7 @@ pub mod uuid {
Ok(Uuid::new_v4().into())
}
#[cfg(uuid_unstable)]
pub fn v7(_: ()) -> Result<Value, Error> {
Ok(Uuid::new_v7().into())
}
#[cfg(not(uuid_unstable))]
pub fn v7(_: ()) -> Result<Value, Error> {
return Err(Error::InvalidFunction {
name: String::from("rand::uuid::v7"),
message: format!("This function is not enabled in this version of SurrealDB."),
});
}
}

View file

@ -132,15 +132,9 @@ impl Id {
Self::String(Ulid::new().to_string())
}
/// Generate a new random UUID
#[cfg(uuid_unstable)]
pub fn uuid() -> Self {
Self::String(Uuid::new_v7().to_raw())
}
/// Generate a new random UUID
#[cfg(not(uuid_unstable))]
pub fn uuid() -> Self {
Self::String(Uuid::new_v4().to_raw())
}
/// Convert the Id to a raw String
pub fn to_raw(&self) -> String {
match self {

View file

@ -66,23 +66,15 @@ impl Deref for Uuid {
}
impl Uuid {
/// Generate a new V4 UUID
/// Generate a new UUID
pub fn new() -> Self {
#[cfg(uuid_unstable)]
{
Self(uuid::Uuid::now_v7())
}
#[cfg(not(uuid_unstable))]
{
Self(uuid::Uuid::new_v4())
}
}
/// Generate a new V4 UUID
pub fn new_v4() -> Self {
Self(uuid::Uuid::new_v4())
}
/// Generate a new V7 UUID
#[cfg(uuid_unstable)]
pub fn new_v7() -> Self {
Self(uuid::Uuid::now_v7())
}