Skip to content

Commit

Permalink
Add support for bytemuck
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsided committed Dec 27, 2023
1 parent 2de1173 commit 72fcc19
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
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"
Expand All @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 72fcc19

Please sign in to comment.