Crate newtype_uuid_macros

Source
Expand description

Procedural macro for newtype-uuid.

This crate provides a procedural macro to help with creating newtype-uuid instances.

For more information, see the documentation for impl_typed_uuid_kinds!.

§Examples

Basic usage:

use newtype_uuid::TypedUuidKind;
use newtype_uuid_macros::impl_typed_uuid_kinds;

impl_typed_uuid_kinds! {
    kinds = {
        User = {},
        BusinessUnit = {},
    },
}

// This generates empty UserKind and BusinessUnitKind enums implementing
// TypedUuidKind, with the tags "user" and "business_unit" respectively.
// Tags are snake_case versions of type names.
assert_eq!(UserKind::tag().as_str(), "user");
assert_eq!(BusinessUnitKind::tag().as_str(), "business_unit");

// The macro also generates UserUuid and BusinessUnitUuid type aliases.
let user_uuid = UserUuid::new_v4();
let business_unit_uuid = BusinessUnitUuid::new_v4();

For more details and examples, see the documentation for impl_typed_uuid_kinds!.

Macros§

impl_typed_uuid_kinds
A function-like procedural macro for implementing typed UUID kinds.