macro_rules! declare_native_blueprint_state {
    (
        blueprint_ident: $blueprint_ident:ident,
        blueprint_snake_case: $blueprint_property_name:ident,
        $(
            outer_blueprint: {
                ident: $outer_blueprint_ident:ident
                $(,)?
            },
        )?
        $(
            generics: {
                $(
                    $generic_property_name:ident: {
                        ident: $generic_ident:ident,
                        description: $generic_description:expr
                        $(,)?
                    }
                ),*
                $(,)?
            },
        )?
        $(
            features: {
                $(
                    $feature_property_name:ident: {
                        ident: $feature_ident:ident,
                        description: $feature_description:expr,
                    }
                ),*
                $(,)?
            },
        )?
        fields: {
            $(
                $field_property_name:ident: {
                    ident: $field_ident:ident,
                    field_type: $field_type:tt
                    $(, condition: $field_condition:expr)?
                    $(, transience: $field_transience:expr)?
                    $(,)? // Optional trailing comma
                }
            ),*
            $(,)? // Optional trailing comma
        },
        collections: {
            $(
                $collection_property_name:ident: $collection_type:ident {
                    entry_ident: $collection_ident:ident,
                    $(mapped_physical_partition: $mapped_physical_partition:expr,)?
                    key_type: $collection_key_type:tt,
                    // The full_key_content is required if it's a sorted index
                    $(full_key_content: $full_key_content:tt,)?
                    value_type: $collection_value_type:tt,
                    allow_ownership: $collection_allow_ownership:expr
                    $(,)? // Optional trailing comma
                }
            ),*
            $(,)? // Optional trailing comma
        }
        $(,)?
    ) => { ... };
}
Expand description

Generates types and typed-interfaces for native blueprints, their state models, features, and schemas.

See the below structure for detail on how it should look - or check out [../package/substates.rs](the package substates definition).

For each field, the following types will be created:

  • <BlueprintIdent><FieldIdent>FieldPayload - a transparent new type for the field content
  • <BlueprintIdent><FieldIdent>FieldSubstate - a type for the full system-wrapped substate

For each collection value, the following types will be created:

  • <BlueprintIdent><CollectionIdent>EntryPayload - a transparent new type for the entry content
  • <BlueprintIdent><CollectionIdent>EntrySubstate - a type for the full system-wrapped substate

For each collection key, the following types will be created:

  • <BlueprintIdent><CollectionIdent>KeyPayload - a new type for the key payload (eg includes the u16 for a sorted index key)

The content of each of the above can take a number of forms. This is configured via specifying the type as one of the following. Only Static is supported for keys at present. By default, you should choose StaticSingleVersioned for fields and collection values.

    {
        kind: StaticSingleVersioned,
    }
    {
        kind: Static,
        content_type: x,
    },
    {
        kind: Generic,
        ident: BlueprintGenericParameterIdent,
    },
    // In future
    {
        kind: StaticMultiVersioned,
        previous_versions: [V1, V2],
        latest: V3,
    }

Choosing StaticSingleVersioned, which will create a forward-compatible enum wrapper with a single version for the content. For Fields, it will assume the existence of a type called <BlueprintIdent><FieldIdent>V1 and will generate the following types:

  • <BlueprintIdent><FieldIdent> - a type alias for the latest version (V1).
  • Versioned<BlueprintIdent><FieldIdent> - the enum wrapper with a single version. This will be the content of <BlueprintIdent><FieldIdent>FieldPayload.

For collection values, it will assume the existence of <BlueprintIdent><CollectionIdent>V1 and generate the following types:

  • <BlueprintIdent><CollectionIdent> - a type alias for the latest version (V1).
  • Versioned<BlueprintIdent><CollectionIdent> - the enum wrapper with a single version. This will be the content of <BlueprintIdent><CollectionIdent>EntryPayload.