From 646dc1a82e32af73949852366443508725e9c0dc Mon Sep 17 00:00:00 2001 From: John Toohey Date: Sun, 15 Oct 2023 12:12:14 +0100 Subject: [PATCH 1/4] Added bytemuck support --- Cargo.toml | 3 +++ src/lib.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 1f14cf3..1ac7f5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,9 @@ fast-rng = ["rng", "rand"] sha1 = ["sha1_smol"] md5 = ["md-5"] +[dependencies] +bytemuck = { version = "1.14.0", optional = true, features = ["derive"] } + # Public: Used in trait impls on `Uuid` [dependencies.serde] default-features = false diff --git a/src/lib.rs b/src/lib.rs index c654d3c..b684b25 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -447,6 +447,10 @@ pub enum Variant { derive(borsh::BorshDeserialize, borsh::BorshSerialize) )] #[repr(transparent)] +#[cfg_attr( + feature = "bytemuck", + derive(bytemuck::Zeroable, bytemuck::Pod, bytemuck::TransparentWrapper) +)] pub struct Uuid(Bytes); impl Uuid { From 3833d095c15c8b524649cc417a38db14ef677815 Mon Sep 17 00:00:00 2001 From: John Toohey Date: Sun, 15 Oct 2023 12:25:30 +0100 Subject: [PATCH 2/4] Make the bytemuck dependency look more like the other dependencies --- Cargo.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ac7f5c..760e257 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,8 +71,12 @@ fast-rng = ["rng", "rand"] sha1 = ["sha1_smol"] md5 = ["md-5"] -[dependencies] -bytemuck = { version = "1.14.0", optional = true, features = ["derive"] } + +# Public: Used in trait impls on `Uuid` +[dependencies.bytemuck] +version = "1.14.0" +optional = true +features = ["derive"] # Public: Used in trait impls on `Uuid` [dependencies.serde] From bcf2b58997a0a87bc11eb276d7f1f6e93979c108 Mon Sep 17 00:00:00 2001 From: John Toohey Date: Wed, 18 Oct 2023 07:24:32 +0100 Subject: [PATCH 3/4] Added Bytemuck to .github/workflows/ci.yml::env::DEP_FEATURES --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b75d64a..bc7167f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Continuous integration env: VERSION_FEATURES: "v1 v3 v4 v5 v6 v7 v8" - DEP_FEATURES: "slog serde arbitrary borsh zerocopy" + DEP_FEATURES: "slog serde arbitrary borsh zerocopy bytemuck" on: pull_request: From 2dad70d3c7dd21d8bda1fc1cf5e04e7cc3dffb85 Mon Sep 17 00:00:00 2001 From: John Toohey Date: Wed, 18 Oct 2023 07:26:07 +0100 Subject: [PATCH 4/4] Added the `bytemuck` optional dependency to `lib.rs` documentation This is so that it is easier to find and more consistent with the other optional dependencies --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index b684b25..5dd12ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,6 +108,7 @@ //! * `fast-rng` - uses a faster algorithm for generating random UUIDs. //! This feature requires more dependencies to compile, but is just as suitable for //! UUIDs as the default algorithm. +//! * `bytemuck` - adds a `Pod` trait implementation to `Uuid` for byte manipulation //! //! # Unstable features //!