diff --git a/src/external/arbitrary_support.rs b/src/external/arbitrary_support.rs index 53047dce..c753f74c 100644 --- a/src/external/arbitrary_support.rs +++ b/src/external/arbitrary_support.rs @@ -23,7 +23,7 @@ impl Arbitrary<'_> for Uuid { impl arbitrary::Arbitrary<'_> for NonNilUuid { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { let uuid = Uuid::arbitrary(u)?; - Self::try_from(uuid).map_err(|_| arbitrary::Error::NotEnoughData) + Self::try_from(uuid).map_err(|_| arbitrary::Error::IncorrectFormat) } fn size_hint(_: usize) -> (usize, Option) { diff --git a/src/external/serde_support.rs b/src/external/serde_support.rs index 42c06493..954a3496 100644 --- a/src/external/serde_support.rs +++ b/src/external/serde_support.rs @@ -145,7 +145,7 @@ impl<'de> Deserialize<'de> for NonNilUuid { { let uuid = Uuid::deserialize(deserializer)?; - NonNilUuid::try_from(uuid).map_err(|_| de::Error::custom("Uuid cannot be nil")) + NonNilUuid::try_from(uuid).map_err(|_| de::Error::invalid_value(de::Unexpected::Other("nil UUID"), &"a non-nil UUID")) } } diff --git a/src/lib.rs b/src/lib.rs index 1c30c383..d9d772cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -437,6 +437,7 @@ pub enum Variant { /// /// The `Uuid` type is always guaranteed to be have the same ABI as [`Bytes`]. #[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[repr(transparent)] #[cfg_attr( all(uuid_unstable, feature = "zerocopy"), derive(IntoBytes, FromBytes, KnownLayout, Immutable, Unaligned) @@ -445,7 +446,6 @@ pub enum Variant { feature = "borsh", derive(borsh_derive::BorshDeserialize, borsh_derive::BorshSerialize) )] -#[repr(transparent)] #[cfg_attr( feature = "bytemuck", derive(bytemuck::Zeroable, bytemuck::Pod, bytemuck::TransparentWrapper) diff --git a/src/non_nil.rs b/src/non_nil.rs index 71db073e..f88fd1a2 100644 --- a/src/non_nil.rs +++ b/src/non_nil.rs @@ -26,6 +26,15 @@ use crate::{ /// - [`Uuid::new_v7`] /// - [`Uuid::now_v7`] /// - [`Uuid::new_v8`] +#[cfg_attr( + all(uuid_unstable, feature = "zerocopy"), + derive(IntoBytes, FromBytes, KnownLayout, Immutable, Unaligned) +)] +#[cfg_attr( + feature = "borsh", + derive(borsh_derive::BorshDeserialize, borsh_derive::BorshSerialize) +)] +#[repr(transparent)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct NonNilUuid(NonZeroU128);