From 88e838e102602f4d89ab65d8245a820158374959 Mon Sep 17 00:00:00 2001 From: Emilia Date: Fri, 29 Dec 2023 18:00:00 -0500 Subject: [PATCH] Switch to v7 UUIDs from v4 v7 UUIDs are timestamp based and thus we can establish a useful total ordering over them; will base colors on this --- Cargo.lock | 15 +++++++++++---- Cargo.toml | 2 +- src/data/plate_instances.rs | 6 ++++-- src/data/transfer.rs | 6 ++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afd2087..0d0e6cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,6 +34,12 @@ dependencies = [ "syn 2.0.16", ] +[[package]] +name = "atomic" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" + [[package]] name = "autocfg" version = "1.1.0" @@ -885,10 +891,11 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "uuid" -version = "1.3.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ + "atomic", "getrandom", "rand", "serde", @@ -898,9 +905,9 @@ dependencies = [ [[package]] name = "uuid-macro-internal" -version = "1.3.3" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f67b459f42af2e6e1ee213cb9da4dbd022d3320788c3fb3e1b893093f1e45da" +checksum = "f49e7f3f3db8040a100710a11932239fd30697115e2ba4107080d8252939845e" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 2adadbf..435d474 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4" wasm-logger = "0.2" regex = "1" lazy_static = "1.4" -uuid = { version = "1.3", features = ["v4", "fast-rng", "macro-diagnostics", "js", "serde"] } +uuid = { version = "1.6", features = ["v7", "fast-rng", "macro-diagnostics", "js", "serde"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" csv = "1.2" diff --git a/src/data/plate_instances.rs b/src/data/plate_instances.rs index 23599b8..f444c18 100644 --- a/src/data/plate_instances.rs +++ b/src/data/plate_instances.rs @@ -5,6 +5,8 @@ use uuid::Uuid; #[derive(PartialEq, Clone, Serialize, Deserialize)] pub struct PlateInstance { pub plate: Plate, + #[serde(rename = "id_v7")] + #[serde(default = "Uuid::now_v7")] id: Uuid, pub name: String, } @@ -16,7 +18,7 @@ impl PlateInstance { plate_type: sort, plate_format: format, }, - id: Uuid::new_v4(), + id: Uuid::now_v7(), name, } } @@ -34,7 +36,7 @@ impl From for PlateInstance { fn from(value: Plate) -> Self { PlateInstance { plate: value, - id: Uuid::new_v4(), + id: Uuid::now_v7(), name: "New Plate".to_string(), } } diff --git a/src/data/transfer.rs b/src/data/transfer.rs index 541106d..b27868b 100644 --- a/src/data/transfer.rs +++ b/src/data/transfer.rs @@ -10,7 +10,9 @@ pub struct Transfer { pub source_id: Uuid, pub dest_id: Uuid, pub name: String, - id: Uuid, + #[serde(rename = "id_v7")] + #[serde(default = "Uuid::now_v7")] + pub id: Uuid, pub transfer_region: TransferRegion, #[serde(default = "default_volume")] pub volume: f32, @@ -44,7 +46,7 @@ impl Transfer { source_id: source.get_uuid(), dest_id: dest.get_uuid(), name, - id: Uuid::new_v4(), + id: Uuid::now_v7(), transfer_region: tr, volume: 2.5, }