newtype-uuid-macros

Crates.ionewtype-uuid-macros
lib.rsnewtype-uuid-macros
version0.1.0
created_at2025-08-19 20:37:29.909745+00
updated_at2025-08-19 20:37:29.909745+00
descriptionProcedural macro for newtype-uuid
homepage
repositoryhttps://github.com/oxidecomputer/newtype-uuid
max_upload_size
id1802449
size39,222
Rain (sunshowers)

documentation

https://docs.rs/newtype-uuid-macros

README

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.

Commit count: 117

cargo fmt