From 72fcc19f2c65cca2fa7584767eaa0e7d491e6064 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 27 Dec 2023 11:23:39 +0100 Subject: [PATCH] Add support for bytemuck --- CHANGELOG.md | 6 ++++++ Cargo.toml | 15 +++++++++++---- src/lib.rs | 8 ++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5b4a16..93e71a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Added support for the `uuid` crate's `bytemuck` feature. + ## 0.6.0 - 2023-06-24 ### Added diff --git a/Cargo.toml b/Cargo.toml index 1e9b336..cabc21a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,14 +6,19 @@ license = "EUPL-1.2" description = "Short URL-safe Base64 encoded UUIDs" repository = "https://github.com/nyris/shortguid-rs" authors = ["Markus Mayer "] +keywords = ["guid", "uuid", "unique"] +categories = ["data-structures"] readme = "README.md" rust-version = "1.67.1" [features] default = ["random"] -arbitrary = ["uuid/arbitrary", "arbitrary/derive"] -random = ["uuid/v4"] -serde = ["dep:serde", "uuid/serde"] +arbitrary = ["uuid/arbitrary", "arbitrary/derive"] # Add support for arbitrary types +random = ["uuid/v4"] # Create random ShortGuid IDs +fast-rng = ["uuid/fast-rng"] # Use a faster (but still sufficiently random) RNG +serde = ["dep:serde", "uuid/serde"] # Serialization and deserialization support +# zerocopy = ["dep:zerocopy", "uuid/zerocopy"] # Zerocopy support +bytemuck = ["dep:bytemuck", "uuid/bytemuck"] # Bytemuck support [[example]] name = "shortguid" @@ -27,12 +32,14 @@ required-features = ["serde"] [dependencies] arbitrary = { version = "1.3.2", optional = true } base64 = "0.21.5" +bytemuck = { version = "1.14.0", optional = true, features = ["derive"] } serde = { version = "1.0.193", optional = true } uuid = "1.6.1" +zerocopy = { version = "0.7.32", optional = true, features = ["derive"] } [dev-dependencies] hex = "0.4.3" -clap = "4.4.10" +clap = "4.4.11" serde_test = "1.0.176" [package.metadata.docs.rs] diff --git a/src/lib.rs b/src/lib.rs index 03feb9f..517a95f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,14 @@ use uuid::Uuid; /// ``` #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +// #[cfg_attr( +// feature = "zerocopy", +// derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::Unaligned) +// )] +#[cfg_attr( + feature = "bytemuck", + derive(bytemuck::Zeroable, bytemuck::Pod, bytemuck::TransparentWrapper) +)] #[repr(transparent)] pub struct ShortGuid(Uuid);