newtype-uuid-macros 0.1.0

Procedural macro for newtype-uuid
Documentation

newtype-uuid-macros

License: MIT OR Apache-2.0 crates.io docs.rs Rust: ^1.79.0

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!.

License

This project is available under the terms of either the Apache 2.0 license or the MIT license.