#[uuid_enum]Expand description
Attribute macro for UUID-backed enums.
Usage:
ⓘ
use uuid_enum::uuid_enum;
#[uuid_enum]
pub enum AccountGrant {
#[uuid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb")]
Owner,
#[uuid("cccccccc-cccc-cccc-cccc-cccccccccccc")]
Manage,
}This expands to a #[repr(u128)] enum where each variant’s discriminant
is the numerical u128 value of its UUID. It also generates:
const ALL: &'static [Self]containing all variantspub const fn as_u128(self) -> u128pub const fn from_u128(raw: u128) -> Option<Self>pub const fn to_uuid(self) -> ::uuid_enum::uuid::Uuidpub const fn from_uuid(id: ::uuid_enum::uuid::Uuid) -> Option<Self>
The UUID values are checked for global uniqueness across the crate. Reuse of the same UUID in two variants (even in different enums using this macro) is a compile error.