From 740f996d95e58be7405bf1f0c7f5ecaa21f8912d Mon Sep 17 00:00:00 2001 From: Trent <2771466+tbillington@users.noreply.github.com> Date: Fri, 16 Feb 2024 20:33:04 +1100 Subject: [PATCH] Add bitcode support --- .github/workflows/ci.yml | 2 +- Cargo.toml | 5 +++++ src/lib.rs | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef99be45..27ac9957 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 bytemuck" + DEP_FEATURES: "slog serde arbitrary borsh zerocopy bytemuck bitcode" on: pull_request: diff --git a/Cargo.toml b/Cargo.toml index b09ca68b..16c712be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,6 +99,11 @@ version = "2" optional = true version = "1.1.3" +# Public: Used in trait impls on `Uuid` +[dependencies.bitcode] +version = "0.5.1" +optional = true + # Public (unstable): Used in `zerocopy` derive # Unstable: also need RUSTFLAGS="--cfg uuid_unstable" to work # This feature may break between releases, or be removed entirely before diff --git a/src/lib.rs b/src/lib.rs index 4c3c9b99..bdc5305e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -114,6 +114,7 @@ //! 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 +//! * `bitcode` - adds the ability to encode and decode a UUID using `bitcode`. //! //! # Unstable features //! @@ -439,6 +440,7 @@ pub enum Variant { all(uuid_unstable, feature = "zerocopy"), derive(AsBytes, FromBytes, Unaligned) )] +#[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))] #[cfg_attr( feature = "borsh", derive(borsh_derive::BorshDeserialize, borsh_derive::BorshSerialize)