Skip to main content

TypedNode

Derive Macro TypedNode 

Source
#[derive(TypedNode)]
{
    // Attributes available to this derive:
    #[node]
}
Expand description

Splits the node field of an ID into named parts.

Apply it to a struct with named u8, u16, or u32 fields, each marked with #[node(bits = N)]. Fields pack in declaration order, most significant first, and their widths must add up to the node bits of the ID format.

ⓘ
#[derive(Debug, Clone, Copy, TypedNode)]
pub struct AppNode {
    #[node(bits = 5)]
    pub worker: u8,
    #[node(bits = 5)]
    pub process: u8,
}

#[typedflake(epoch = "2025-01-01", node = AppNode)]
pub struct UserId(i64);

The field order is part of the persisted ID format.